Add hasUnreadMention to NCRoom object.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2021-10-05 18:05:02 +02:00
Родитель af309fc537
Коммит ebc37c0334
3 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -104,6 +104,7 @@ extern NSString * const NCRoomObjectTypeSharePassword;
- (BOOL)isNameEditable;
- (BOOL)isLeavable;
- (BOOL)userCanStartCall;
- (BOOL)hasUnreadMention;
- (NSString *)deletionMessage;
- (NSString *)notificationLevelString;
- (NSString *)stringForNotificationLevel:(NCRoomNotificationLevel)level;

Просмотреть файл

@ -176,6 +176,11 @@ NSString * const NCRoomObjectTypeSharePassword = @"share:password";
return YES;
}
- (BOOL)hasUnreadMention
{
return self.unreadMention || self.unreadMentionDirect || (self.type == kNCRoomTypeOneToOne && self.unreadMessages > 0);
}
- (BOOL)isLeavable
{
// Allow users to leave when there are no moderators in the room

Просмотреть файл

@ -481,7 +481,7 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
_lastRoomWithMentionIndexPath = nil;
for (int i = 0; i < _rooms.count; i++) {
NCRoom *room = [_rooms objectAtIndex:i];
if (room.unreadMention || room.unreadMentionDirect || (room.type == kNCRoomTypeOneToOne && room.unreadMessages > 0)) {
if (room.hasUnreadMention) {
_lastRoomWithMentionIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
}
}
@ -601,7 +601,7 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
if (_lastRoomWithMentionIndexPath) {
for (int i = (int)lastVisibleRowIndexPath.row; i <= (int)_lastRoomWithMentionIndexPath.row; i++) {
NCRoom *room = [_rooms objectAtIndex:i];
if (room.unreadMention || room.unreadMentionDirect || (room.type == kNCRoomTypeOneToOne && room.unreadMessages > 0)) {
if (room.hasUnreadMention) {
_nextRoomWithMentionIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
break;
}