From 18e78864c851e7e8bc4e5c7acc5dcd3a18de4543 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Thu, 10 Mar 2022 15:33:50 +0000 Subject: [PATCH 1/3] Do not show user indicators when the view controller is not visible --- .../UserIndicatorPresenterWrapper.swift | 2 ++ .../Modules/Common/Recents/RecentsViewController.m | 11 +++++++++-- Riot/Modules/Room/RoomViewController.m | 14 ++++++++++++-- changelog.d/5801.bugfix | 1 + 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 changelog.d/5801.bugfix diff --git a/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift b/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift index f7faa03f6e..a4ae0d44eb 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 99c348b1ca..7d4336ebf6 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -64,6 +64,10 @@ @interface RecentsViewController () Date: Thu, 10 Mar 2022 17:32:25 +0000 Subject: [PATCH 2/3] Name changes --- .../UserIndicatorPresenterWrapper.swift | 10 +++++----- .../Common/Recents/RecentsViewController.m | 20 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift b/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift index a4ae0d44eb..7d1bd9d3b3 100644 --- a/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift +++ b/Riot/Modules/Common/ActivityIndicator/UserIndicatorPresenterWrapper.swift @@ -30,13 +30,13 @@ import CommonKit self.presenter = presenter } - @objc func presentActivityIndicator() { - presentActivityIndicator(label: VectorL10n.homeSyncing) + @objc func presentLoadingIndicator() { + presentLoadingIndicator(label: VectorL10n.homeSyncing) } - @objc func presentActivityIndicator(label: String) { + @objc func presentLoadingIndicator(label: String) { guard loadingIndicator == nil else { - // The app is very liberal with calling `presentActivityIndicator` (often not matched by corresponding `removeCurrentActivityIndicator`), + // The app is very liberal with calling `presentLoadingIndicator` (often not matched by corresponding `dismissLoadingIndicator`), // so there is no reason to keep adding new indiciators if there is one already showing. return } @@ -45,7 +45,7 @@ import CommonKit loadingIndicator = presenter.present(.loading(label: label, isInteractionBlocking: false)) } - @objc func dismissActivityIndicator() { + @objc func dismissLoadingIndicator() { 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 7d4336ebf6..dab50e3153 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -64,9 +64,8 @@ @interface RecentsViewController () Date: Thu, 10 Mar 2022 17:40:23 +0000 Subject: [PATCH 3/3] Add more comments --- Riot/Modules/Room/RoomViewController.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 296585b96a..ffe224edef 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -569,7 +569,7 @@ - (void)viewWillDisappear:(BOOL)animated [VoiceMessageMediaServiceProvider.sharedProvider pauseAllServices]; // Stop the loading indicator even if the session is still in progress - [self stopLoadingIndicator]; + [self stopLoadingUserIndicator]; } - (void)viewDidAppear:(BOOL)animated @@ -937,10 +937,14 @@ - (void)onMatrixSessionChange self.updateRoomReadMarker = NO; } +#pragma mark - Loading indicators + - (BOOL)providesCustomActivityIndicator { return [self.delegate roomViewControllerCanDelegateUserIndicators:self]; } +// Override of a legacy method to determine whether to use a newer implementation instead. +// Will be removed in the future https://github.com/vector-im/element-ios/issues/5608 - (void)startActivityIndicator { if ([self providesCustomActivityIndicator]) { [self.delegate roomViewControllerDidStartLoading:self]; @@ -949,6 +953,8 @@ - (void)startActivityIndicator { } } +// Override of a legacy method to determine whether to use a newer implementation instead. +// Will be removed in the future https://github.com/vector-im/element-ios/issues/5608 - (void)stopActivityIndicator { if (notificationTaskProfile) @@ -962,14 +968,14 @@ - (void)stopActivityIndicator // 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 stopLoadingIndicator]; + [self stopLoadingUserIndicator]; } } else { [super stopActivityIndicator]; } } -- (void)stopLoadingIndicator +- (void)stopLoadingUserIndicator { [self.delegate roomViewControllerDidStopLoading:self]; }