-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not show user indicators when the view controller is not visible #5804
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
loadingIndicator = nil | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,10 @@ @interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegat | |
// 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing mandatory. This name confused me a bit at first because I believed that you wanted to add the capability to enable / disable the activity indicator from other instance or subclasses. Why not not calling this property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea I guess that is more typical for cases like this and will be clearer. |
||
|
||
// Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change. | ||
__weak id kThemeServiceDidChangeThemeNotificationObserver; | ||
} | ||
|
@@ -266,6 +270,8 @@ - (void)viewWillAppear:(BOOL)animated | |
[super viewWillAppear:animated]; | ||
|
||
[self.screenTracker trackScreen]; | ||
|
||
isUserIndicatorEnabled = YES; | ||
|
||
// Reset back user interactions | ||
self.userInteractionEnabled = YES; | ||
|
@@ -317,6 +323,7 @@ - (void)viewWillDisappear:(BOOL)animated | |
kMXNotificationCenterDidUpdateRulesObserver = nil; | ||
} | ||
|
||
isUserIndicatorEnabled = NO; | ||
[self stopActivityIndicator]; | ||
} | ||
|
||
|
@@ -2408,15 +2415,15 @@ - (BOOL)providesCustomActivityIndicator { | |
} | ||
|
||
- (void)startActivityIndicatorWithLabel:(NSString *)label { | ||
if (self.indicatorPresenter) { | ||
if (self.indicatorPresenter && isUserIndicatorEnabled) { | ||
[self.indicatorPresenter presentActivityIndicatorWithLabel:label]; | ||
} else { | ||
[super startActivityIndicator]; | ||
} | ||
} | ||
|
||
- (void)startActivityIndicator { | ||
if (self.indicatorPresenter) { | ||
if (self.indicatorPresenter && isUserIndicatorEnabled) { | ||
[self.indicatorPresenter presentActivityIndicator]; | ||
} else { | ||
[super startActivityIndicator]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -567,7 +567,9 @@ - (void)viewWillDisappear:(BOOL)animated | |
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 @@ - (void)stopActivityIndicator | |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a pending of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There already is a |
||
{ | ||
[self.delegate roomViewControllerDidStopLoading:self]; | ||
} | ||
|
||
- (void)displayRoom:(MXKRoomDataSource *)dataSource | ||
{ | ||
// Remove potential preview Data | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Activity Indicators: Do not show user indicators when the view controller is not visible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
activity
does not belong here, because that name is currently only associated withUIActivityIndicator
, which this system is not using. If anything I can probably rename thepresentActivityIndicator
methods.