diff --git a/Riot/Modules/Home/HomeViewController.h b/Riot/Modules/Home/HomeViewController.h index aa38c289a..a24b8ccdd 100644 --- a/Riot/Modules/Home/HomeViewController.h +++ b/Riot/Modules/Home/HomeViewController.h @@ -17,11 +17,21 @@ #import "RecentsViewController.h" +/** + Notification to be posted when room list data is ready. + */ +FOUNDATION_EXPORT NSString *const HomeViewControllerRoomListDataReadyNotification; + /** The `HomeViewController` screen is the main app screen. */ @interface HomeViewController : RecentsViewController +/** + Listen HomeViewControllerRoomListDataReadyNotification for changes. + */ +@property (nonatomic, assign, readonly, getter=isRoomListDataReady) BOOL roomListDataReady; + + (instancetype)instantiate; @end diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index 19025bb6c..4fb727320 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -26,6 +26,8 @@ #import "MXRoom+Riot.h" +NSString *const HomeViewControllerRoomListDataReadyNotification = @"HomeViewControllerRoomListDataReadyNotification"; + @interface HomeViewController () { RecentsDataSource *recentsDataSource; @@ -46,6 +48,8 @@ @property (nonatomic, strong) CrossSigningSetupBannerCell *keyVerificationSetupBannerPrototypeCell; @property (nonatomic, strong) CrossSigningSetupCoordinatorBridgePresenter *crossSigningSetupCoordinatorBridgePresenter; +@property (nonatomic, assign, readwrite) BOOL roomListDataReady; + @end @implementation HomeViewController @@ -72,6 +76,8 @@ { [super viewDidLoad]; + self.roomListDataReady = NO; + self.view.accessibilityIdentifier = @"HomeVCView"; self.recentsTableView.accessibilityIdentifier = @"HomeVCTableView"; @@ -859,4 +865,18 @@ + recentsDataSource.serverNoticeCellDataArray.count; } +- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes +{ + [super dataSource:dataSource didCellChange:changes]; + + if (dataSource.state == MXKDataSourceStateReady) + { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + self.roomListDataReady = YES; + [[NSNotificationCenter defaultCenter] postNotificationName:HomeViewControllerRoomListDataReadyNotification object:nil]; + }); + } +} + @end