Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2018-08-01 17:54:34 +02:00
Родитель 82c8b3c8d2
Коммит 4d464ef047
3 изменённых файлов: 5 добавлений и 2 удалений

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

@ -132,8 +132,9 @@ NSString * const kNCSpreedAPIVersion = @"/apps/spreed/api/v1";
[rooms addObject:ncRoom];
}
// Sort by lastPing
NSSortDescriptor *valueDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastPing" ascending:NO];
// Sort by lastPing or lastActivity
NSString *sortKey = ([[NCSettingsController sharedInstance] serverHasTalkCapability:kCapabilityLastRoomActivity]) ? @"lastActivity" : @"lastPing";
NSSortDescriptor *valueDescriptor = [[NSSortDescriptor alloc] initWithKey:sortKey ascending:NO];
NSArray *descriptors = [NSArray arrayWithObject:valueDescriptor];
[rooms sortUsingDescriptors:descriptors];

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

@ -31,6 +31,7 @@ typedef enum NCRoomType {
@property (nonatomic, assign) NSInteger unreadMessages;
@property (nonatomic, copy) NSString *guestList;
@property (nonatomic, copy) NSDictionary *participants;
@property (nonatomic, assign) NSInteger lastActivity;
+ (instancetype)roomWithDictionary:(NSDictionary *)roomDict;

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

@ -28,6 +28,7 @@
room.unreadMessages = [[roomDict objectForKey:@"unreadMessages"] integerValue];
room.guestList = [roomDict objectForKey:@"guestList"];
room.participants = [roomDict objectForKey:@"participants"];
room.lastActivity = [[roomDict objectForKey:@"lastActivity"] integerValue];
id name = [roomDict objectForKey:@"name"];
if ([name isKindOfClass:[NSString class]]) {