Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
MXKRoomDataSourceManager: Add missedHighlightDiscussionsCount method.
Browse files Browse the repository at this point in the history
Return the current number of rooms with unread highlighted messages.

related to element-hq/element-ios#563
  • Loading branch information
giomfo committed Sep 5, 2016
1 parent 8e9d838 commit eaa5783
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MatrixKit/Models/Room/MXKRoomDataSourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ typedef enum : NSUInteger {
*/
+ (NSUInteger)missedDiscussionsCount;

/**
The current number of rooms with unread highlighted messages.
*/
+ (NSUInteger)missedHighlightDiscussionsCount;

/**
Mark all messages as read.
*/
Expand Down
28 changes: 28 additions & 0 deletions MatrixKit/Models/Room/MXKRoomDataSourceManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ + (NSUInteger)missedDiscussionsCount
return roomCount;
}

+ (NSUInteger)missedHighlightDiscussionsCount
{
NSUInteger roomCount = 0;

// Sum here all the room with unread highlighted messages (retrieved from the existing room data sources)
@synchronized(_roomDataSourceManagers)
{
NSArray *mxSessionIds = _roomDataSourceManagers.allKeys;
for (NSString *mxSessionId in mxSessionIds)
{
MXKRoomDataSourceManager *roomDataSourceManager = [_roomDataSourceManagers objectForKey:mxSessionId];
if (roomDataSourceManager)
{
NSArray *roomDataSources = roomDataSourceManager->roomDataSources.allValues;
for (MXKRoomDataSource *roomDataSource in roomDataSources)
{
if (roomDataSource.highlightCount)
{
roomCount ++;
}
}
}
}
}

return roomCount;
}

+ (void)markAllMessagesAsRead
{
// Reset the unread count in all the existing room data sources.
Expand Down

0 comments on commit eaa5783

Please # to comment.