From 81f254e133d1c6aee439f461acf85f8a67ee1425 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 18 Feb 2019 18:25:50 +0100 Subject: [PATCH] Key backup: avoid to refresh the home room list on every backup state change A possible mitigation for #2265 --- CHANGES.rst | 7 +++++-- .../Recents/DataSources/RecentsDataSource.m | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1e8306636..7880378a7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,9 +1,12 @@ Changes in 0.8.1 (2019-02-) =============================================== +Improvements: + * Key backup: avoid to refresh the home room list on every backup state change (#2265). + Bug fix: - * Fix text color in room preview (PR #2261) - * Fix navigation bar background after accepting an invite (PR #2261) + * Fix text color in room preview (PR #2261). + * Fix navigation bar background after accepting an invite (PR #2261). Changes in 0.8.0 (2019-02-15) =============================================== diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index 846ab732e..5f4b2707f 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -165,10 +165,13 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou - (void)keyBackupStateDidChangeNotification:(NSNotification*)notification { - [self forceRefresh]; + if ([self updateKeyBackupBanner]) + { + [self forceRefresh]; + } } -- (void)updateKeyBackupBanner +- (BOOL)updateKeyBackupBanner { KeyBackupBanner keyBackupBanner = KeyBackupBannerNone; @@ -207,8 +210,12 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou break; } } - + + BOOL updated = (self.keyBackupBanner != keyBackupBanner); + self.keyBackupBanner = keyBackupBanner; + + return updated; } - (void)hideKeyBackupBanner:(KeyBackupBanner)keyBackupBanner @@ -1227,6 +1234,8 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou - (void)refreshRoomsSections { + NSDate *startDate = [NSDate date]; + [invitesCellDataArray removeAllObjects]; [favoriteCellDataArray removeAllObjects]; [peopleCellDataArray removeAllObjects]; @@ -1240,8 +1249,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou keyBackupBannerSection = directorySection = favoritesSection = peopleSection = conversationSection = lowPrioritySection = serverNoticeSection = invitesSection = -1; - [self updateKeyBackupBanner]; - if (displayedRecentsDataSourceArray.count > 0) { // FIXME manage multi accounts @@ -1485,6 +1492,8 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou }]; } } + + NSLog(@"[RecentsDataSource] refreshRoomsSections: Done in %.0fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000); } - (void)dataSource:(MXKDataSource*)dataSource didCellChange:(id)changes