diff --git a/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift b/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift index f7faa03f6..a4ae0d44e 100644 --- a/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift +++ b/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift @@ -41,10 +41,12 @@ import CommonKit return } + MXLog.debug("[UserIndicatorPresenterWrapper] Present loading indicator") loadingIndicator = presenter.present(.loading(label: label, isInteractionBlocking: false)) } @objc func dismissActivityIndicator() { + MXLog.debug("[UserIndicatorPresenterWrapper] Dismiss loading indicator") loadingIndicator = nil } diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 99c348b1c..7d4336ebf 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -64,6 +64,10 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro // when the user selects it. UISearchBar *tableSearchBar; + // Flag determining whether the view controller is ready to use (potentially shared) user indicators + // depending on whether the controller is visible or not + BOOL isUserIndicatorEnabled; + // Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change. __weak id kThemeServiceDidChangeThemeNotificationObserver; } @@ -266,6 +270,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro [super viewWillAppear:animated]; [self.screenTracker trackScreen]; + + isUserIndicatorEnabled = YES; // Reset back user interactions self.userInteractionEnabled = YES; @@ -317,6 +323,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro kMXNotificationCenterDidUpdateRulesObserver = nil; } + isUserIndicatorEnabled = NO; [self stopActivityIndicator]; } @@ -2408,7 +2415,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro } - (void)startActivityIndicatorWithLabel:(NSString *)label { - if (self.indicatorPresenter) { + if (self.indicatorPresenter && isUserIndicatorEnabled) { [self.indicatorPresenter presentActivityIndicatorWithLabel:label]; } else { [super startActivityIndicator]; @@ -2416,7 +2423,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro } - (void)startActivityIndicator { - if (self.indicatorPresenter) { + if (self.indicatorPresenter && isUserIndicatorEnabled) { [self.indicatorPresenter presentActivityIndicator]; } else { [super startActivityIndicator]; diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 8288c6f81..296585b96 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -567,7 +567,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; isAppeared = NO; [VoiceMessageMediaServiceProvider.sharedProvider pauseAllServices]; - [self stopActivityIndicator]; + + // Stop the loading indicator even if the session is still in progress + [self stopLoadingIndicator]; } - (void)viewDidAppear:(BOOL)animated @@ -956,14 +958,22 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; notificationTaskProfile = nil; } if ([self providesCustomActivityIndicator]) { + // The legacy super implementation of `stopActivityIndicator` contains a number of checks grouped under `canStopActivityIndicator` + // to determine whether the indicator can be stopped or not (and the method should thus rather be called `stopActivityIndicatorIfPossible`). + // Since the newer indicators are not calling super implementation, the check for `canStopActivityIndicator` has to be performed manually. if ([self canStopActivityIndicator]) { - [self.delegate roomViewControllerDidStopLoading:self]; + [self stopLoadingIndicator]; } } else { [super stopActivityIndicator]; } } +- (void)stopLoadingIndicator +{ + [self.delegate roomViewControllerDidStopLoading:self]; +} + - (void)displayRoom:(MXKRoomDataSource *)dataSource { // Remove potential preview Data diff --git a/changelog.d/5801.bugfix b/changelog.d/5801.bugfix new file mode 100644 index 000000000..3d58e1ee8 --- /dev/null +++ b/changelog.d/5801.bugfix @@ -0,0 +1 @@ +Activity Indicators: Do not show user indicators when the view controller is not visible