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

Add forced logout flow when the proxy is no longer available #3458

Conversation

jmartinesp
Copy link
Member

Content

  • Added MatrixClient.isSlidingSyncProxyAvailable() function.
  • Modifies ErrorDialog component so it can be made non-dismissable if needed, added a separate submit action from the dismiss one.
  • Check if a forced migration to native sliding sync is needed (the user is using the proxy, which is no longer available), and display the error dialog on top of all screens.
  • Rework the login process so it tries to log in using native sliding sync if available and enabled, then using the proxy. Also enable native sliding sync support by default.

Motivation and context

Second part of #3427.

Screenshots / GIFs

Tests

This is quite difficult to test unless you either change the check in LoggedInFlowNode or make the return value of Client::available_sliding_sync_versions() in Rust to just the native one. If you manage to do one of them:

  • Open the app, the dialog should be displayed.
  • It must not be dismissable and should prevent using the app.
  • Restarting the app should make no change.
  • Tapping on logout and upgrade should do exactly that.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

jmartinesp and others added 9 commits September 13, 2024 12:51
…or the submit action.

Also make the title text optional and dismissing the dialog by tapping outside/going back configurable.
…longer available.

In that case, display the non-dismissable dialog and force the user to log out after enabling SSS.
1. Always try native/simplified sliding sync login first, if available.
2. Then, if it wasn't available or failed with an sliding sync not supported error, try with the proxy instead (either discovered proxy or forced custom one).
@jmartinesp jmartinesp added the PR-Feature For a new feature label Sep 13, 2024
@jmartinesp jmartinesp requested a review from a team as a code owner September 13, 2024 13:15
@jmartinesp jmartinesp requested review from ganfra and removed request for a team September 13, 2024 13:15
Copy link
Contributor

github-actions bot commented Sep 13, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/n5VjnC

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 6 lines in your changes missing coverage. Please review.

Project coverage is 82.63%. Comparing base (da3f5e0) to head (b6bc7cb).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...io/element/android/appnav/loggedin/LoggedInView.kt 84.61% 1 Missing and 1 partial ⚠️
...ement/android/appnav/loggedin/LoggedInPresenter.kt 80.00% 0 Missing and 1 partial ⚠️
...nt/android/features/leaveroom/api/LeaveRoomView.kt 0.00% 1 Missing ⚠️
...d/features/lockscreen/impl/unlock/PinUnlockView.kt 50.00% 1 Missing ⚠️
...nfirmaccountprovider/ConfirmAccountProviderView.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3458      +/-   ##
===========================================
+ Coverage    82.62%   82.63%   +0.01%     
===========================================
  Files         1701     1701              
  Lines        40015    40047      +32     
  Branches      4868     4872       +4     
===========================================
+ Hits         33061    33092      +31     
- Misses        5233     5234       +1     
  Partials      1721     1721              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

Some remarks, otherwise LGTM

Comment on lines +537 to +538
override suspend fun isSlidingSyncProxySupported(): Boolean {
return client.availableSlidingSyncVersions().any { it is SlidingSyncVersion.Proxy }
Copy link
Member

Choose a reason for hiding this comment

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

Can't this fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently not, if the SDK can't load the data (network error, one of the config files not existing...) it just returns an empty list.

Copy link
Member

Choose a reason for hiding this comment

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

Can we try to move logic to the LoggedInPresenter and LoggedInView?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can try 🤞 .

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

PR should avoid updating all translations, just the ones you need for your work would be better :)

Copy link
Member Author

@jmartinesp jmartinesp Sep 16, 2024

Choose a reason for hiding this comment

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

That's actually what I did, but I had to remove the translations in other languages for a couple of strings that are no longer in the project because otherwise the code quality checks wouldn't pass.

@jmartinesp jmartinesp added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 16, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 16, 2024
Copy link

sonarcloud bot commented Sep 16, 2024

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 16, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 16, 2024
@jmartinesp jmartinesp enabled auto-merge (squash) September 16, 2024 08:50
@jmartinesp jmartinesp merged commit 663362a into develop Sep 16, 2024
30 checks passed
@jmartinesp jmartinesp deleted the feat/jme/implement-forced-logout-for-proxy-not-available-use-case branch September 16, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Feature For a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants