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 banner for optional migration to simplified sliding sync #3429

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

jmartinesp
Copy link
Member

Content

  • Add MatrixClient.isNativeSlidingSyncSupported() and MatrixClient.isUsingNativeSlidingSync to check whether the home server supports native sliding sync and we're already using it.
  • Add NativeSlidingSyncMigrationBanner composable to the RoomList screen when the home server supports native sliding sync but the current session is not using it.
  • Add an extra logout successful action to the logout flow, create EnableNativeSlidingSyncUseCase so it can be used there.

Motivation and context

Closes #3427.

Screenshots / GIFs

In the PR.

Tests

  • With simplified sliding sync disabled in the client, log into a homeserver which has it enabled (i.e. element.io).
  • You should see the migration banner.
  • When tapping in log out & upgrade, a confirmation will be displayed.
  • Once logged out if you log in again you'll be using SSS.
  • The banner won't be visible then.

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 2 commits September 9, 2024 13:47
- Add `MatrixClient.isNativeSlidingSyncSupported()` and `MatrixClient.isUsingNativeSlidingSync` to check whether the home server supports native sliding sync and we're already using it.
- Add `NativeSlidingSyncMigrationBanner` composable to the `RoomList` screen when the home server supports native sliding sync but the current session is not using it.
- Add an extra logout successful action to the logout flow, create `EnableNativeSlidingSyncUseCase` so it can be used there.
@jmartinesp jmartinesp added the PR-Feature For a new feature label Sep 9, 2024
@jmartinesp jmartinesp requested a review from a team as a code owner September 9, 2024 12:13
@jmartinesp jmartinesp requested review from bmarty and removed request for a team September 9, 2024 12:13
Copy link
Contributor

github-actions bot commented Sep 9, 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/icU2iG

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

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

Project coverage is 82.65%. Comparing base (fc0bb64) to head (6398083).
Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
...id/features/logout/impl/DefaultLogoutEntryPoint.kt 0.00% 3 Missing ⚠️
...ndroid/features/roomlist/impl/RoomListPresenter.kt 75.00% 0 Missing and 2 partials ⚠️
...mpl/components/NativeSlidingSyncMigrationBanner.kt 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3429   +/-   ##
========================================
  Coverage    82.65%   82.65%           
========================================
  Files         1705     1707    +2     
  Lines        40076    40115   +39     
  Branches      4881     4885    +4     
========================================
+ Hits         33125    33158   +33     
- Misses        5233     5236    +3     
- Partials      1718     1721    +3     

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

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM, some small non-blocking remarks.

@@ -176,6 +182,7 @@ class RoomListPresenter @Inject constructor(
derivedStateOf {
when {
currentSecurityBannerDismissed -> SecurityBannerState.None
needsSlidingSyncMigration -> SecurityBannerState.NeedsNativeSlidingSyncMigration
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure that the NeedsNativeSlidingSyncMigration banner has higher priority than the SetUpRecovery and RecoveryKeyConfirmation banner?

It will fully hide the two latter, since if NeedsNativeSlidingSyncMigration is dismissed, currentSecurityBannerDismissed will be true and the other banner will never be displayed again (until the user logout and login again).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you're right, this one should have the lowest priority.

@@ -77,6 +77,8 @@ class FakeMatrixClient(
private val clearCacheLambda: () -> Unit = { lambdaError() },
private val userIdServerNameLambda: () -> String = { lambdaError() },
private val getUrlLambda: (String) -> Result<String> = { lambdaError() },
var isNativeSlidingSyncSupportedLambda: suspend () -> Boolean = { true },
var isUsingNativeSlidingSyncLambda: () -> Boolean = { true },
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to use private val for lambda like this. Also, they seem to be unused, maybe add a quick unit test to check the value of needsSlidingSyncMigration?

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 usually prefer using the public var because that way you can set up both the value on the constructor or later in the tests if you need to change it without having to create a new method just for setting it.

) {
operator fun invoke() {
appCoroutineScope.launch {
appPreferencesStore.setSimplifiedSlidingSyncEnabled(true)
Copy link
Member

Choose a reason for hiding this comment

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

There is maybe an issue if the user decides to login using another homeserver... I agree this is an edge case and this is temporary code, but with the current codebase, but we should maybe have a setting per server...

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this forces you to log out, I don't think most users will try it and then change their mind and log into another home server. Besides, changing this would required quite a few logic changes and maybe UI ones for the developer options toggle, and it seems like an overkill for something like this.

What we could do, maybe, is that when this is enabled, the 1st login attempt will be tried using a native sliding sync config, then if it fails with a not supported error the 2nd one will use the previous proxy one as a fallback. WDYT? Maybe I can add this in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

OK, let's not do anything then.
Also there is another (limited) risk of user seeing the banner and decide to logout from the settings. In this case, there will be no usage of the SSS and the banner will reappear.

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 9, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 9, 2024
Copy link

sonarcloud bot commented Sep 9, 2024

@jmartinesp jmartinesp merged commit 67e262f into develop Sep 9, 2024
26 checks passed
@jmartinesp jmartinesp deleted the feat/jme/3427-offer-user-to-transition-to-sss branch September 9, 2024 16:13
@xundeenergie
Copy link

xundeenergie commented Sep 10, 2024

I've just installed 0.5.3

And i logged out and in again.

I'm missing info how to configure my server for simplified sliding sync.

on the proxy i added , "org.matrix.msc3575.proxy": { "url": "https://matrix.schuerz.at" } to the .well-known file, like i had it before with the explicit syncv3-server.
Because, when i delete this entry, element x says "Sorry, your server does not provide sliding sync"
So i added it back again.

Then i removed in my matrix-hosts nginx-config the part for the external sliding sync...

  1. When i log in with external sliding sync active i can login and verify the session.
  2. When i try to log in without external sliding sync i can not login and not verify the session.

So i logged in with acitve external sliding sync, then i removed the entry for the external sliding sync in nginx.conf from my matrix-server and reloaded the nginx config.
element x still works. But the banner for "Now your server provides a faster protocoll... " flickers very fast on top of my room-list. I can see a button, but i can not press it.

It seems, it should do, what this PR promises... but i can not use it.

It there somewhere some docu how to configure matrix- and proxy-server and nginx correctly to use simplified sliding sync?

Here is a short screencast to show, what i mean.
It happens on 2 different androids. Samsung A53 and Google Pixel 7 with GrapheneOS

https://kino.schuerz.at/w/uSL7U7KgwspV4Spni3TpE8

@xundeenergie
Copy link

I tried a lot to hit the button. And once i got it.
then i was asked to logout.
What i did.
Logged in again and verification was possible with SSS (i think so, because i removed the location for external sliding-sync server from matrix nginx.conf)

So my configuration now is:
On reverse-Proxy i still have the entry for msc3575.proxy, whicht points to my matrix-server.
On matrix-servers nginx i have no entry for a sliding-sync service.
homeserver.yaml has no additional entry for sliding-sync. it is as before.

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.

Offer user to transition to SSS (Android)
3 participants