Skip to content
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

Merged
merged 3 commits into from
Mar 11, 2022

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Mar 10, 2022

Fixes #5801

The architecture around user indicators is still not quite ideal, now that we have global user indicators it becomes problematic when view controllers attempt to display something whilst they are not actually visible. For example most view controllers subclass from MXViewController which monitors the MXSession at all times and starts / stops activity indicator accordingly.

For now I am simply adding some flags to avoid presenting when the view controller is not visible, but this is not a robust enough solution and something else will need to be put in place. In an idea case the loading is more centralized and each room communicates its state changes via some delegate, but this obviously requires a bigger change.

Another angle to this is removing all the state change monitoring from each view controller when the view controller isn't actually visible. This should be done anyways but could have further consequences, so best done outside of a hotfix.

@Anderas Anderas requested review from a team and gileluard and removed request for a team March 10, 2022 16:24
Copy link
Contributor

@gileluard gileluard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some comments. Feel free to apply some of the updates I proposed.

@@ -41,10 +41,12 @@ import CommonKit
return
}

MXLog.debug("[UserIndicatorPresenterWrapper] Present loading indicator")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MXLog.debug("[UserIndicatorPresenterWrapper] Present loading indicator")
MXLog.debug("[UserIndicatorPresenterWrapper] Present activity indicator")

Copy link
Contributor Author

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 with UIActivityIndicator, which this system is not using. If anything I can probably rename the presentActivityIndicator methods.

loadingIndicator = presenter.present(.loading(label: label, isInteractionBlocking: false))
}

@objc func dismissActivityIndicator() {
MXLog.debug("[UserIndicatorPresenterWrapper] Dismiss loading indicator")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MXLog.debug("[UserIndicatorPresenterWrapper] Dismiss loading indicator")
MXLog.debug("[UserIndicatorPresenterWrapper] Dismiss activity indicator")

}
} else {
[super stopActivityIndicator];
}
}

- (void)stopLoadingIndicator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a pending of presentActivityIndicator shouldn't we call this method stopActivityIndicator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is a stopActivityIndicator, which makes this all the more confusing, ie the legacy stopActivityIndicator will call the newer stopLoadingIndicator. The reason I extracted this out is so that we can call the latter directly from viewWillDissapear and avoid the canStop.... I think we need to move away from the legacy implementation ASAP, supporting both is turning this into a mess.

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 isViewVisible as it is exactly what you aim to check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@github-actions
Copy link

github-actions bot commented Mar 10, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/gyeEuK

@Anderas Anderas requested a review from gileluard March 10, 2022 17:32
Copy link
Contributor

@gileluard gileluard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great and sorry for all the naming suggestion :)

@Anderas Anderas merged commit 53245af into hotfix/1.8.5 Mar 11, 2022
@Anderas Anderas deleted the andy/5801_dismiss_indicators branch March 11, 2022 08:16
@Anderas
Copy link
Contributor Author

Anderas commented Mar 11, 2022

Great and sorry for all the naming suggestion :)

Not at all, thanks for your helpful feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants