diff --git a/matrixConsole/ViewController/RecentsViewController.m b/matrixConsole/ViewController/RecentsViewController.m index 2b5d7b51e..8c67c1730 100644 --- a/matrixConsole/ViewController/RecentsViewController.m +++ b/matrixConsole/ViewController/RecentsViewController.m @@ -117,9 +117,6 @@ // Refresh display [self configureView]; [[MatrixHandler sharedHandler] addObserver:self forKeyPath:@"isResumeDone" options:0 context:nil]; - // Add observer to force refresh when a recent last description is updated thanks to back pagination - // (This happens when the current last event description is blank, a back pagination is triggered to display non empty description) - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(configureView) name:kRecentRoomUpdatedByBackPagination object:nil]; } - (void)viewWillDisappear:(BOOL)animated { @@ -136,7 +133,6 @@ _preSelectedRoomId = nil; [[MatrixHandler sharedHandler] removeObserver:self forKeyPath:@"isResumeDone"]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kRecentRoomUpdatedByBackPagination object:nil]; } - (void)viewDidAppear:(BOOL)animated { @@ -228,6 +224,7 @@ MatrixHandler *mxHandler = [MatrixHandler sharedHandler]; [self startActivityIndicator]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:kRecentRoomUpdatedByBackPagination object:nil]; if (mxHandler.mxSession) { // Check matrix handler status @@ -334,7 +331,11 @@ [self.tableView reloadData]; } - if (!recents) { + if (recents) { + // Add observer to force refresh when a recent last description is updated thanks to back pagination + // (This happens when the current last event description is blank, a back pagination is triggered to display non empty description) + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onRecentRoomUpdatedByBackPagination) name:kRecentRoomUpdatedByBackPagination object:nil]; + } else { // Remove potential listener if (recentsListener && mxHandler.mxSession) { [mxHandler.mxSession removeListener:recentsListener]; @@ -345,6 +346,10 @@ [self updateTitleView]; } +- (void)onRecentRoomUpdatedByBackPagination { + [self.tableView reloadData]; +} + - (void)updateTitleView { NSString *title = @"Recents"; if (unreadCount) {