Skip to content

Commit beffba1

Browse files
renovate[bot]jmartinespElementBot
authored
fix(deps): update dependency org.matrix.rustcomponents:sdk-android to v25 (#4273)
* fix(deps): update dependency org.matrix.rustcomponents:sdk-android to v25 * Adapt to SDK changes: - Remove logic related to sliding sync proxy, leaving just the minimum needed to detect its usage on the current session data. - Remove code associated with the opt-in migration to native sliding sync, since it's now mandatory. - Remove toggle between proxy/native sliding sync. - Some fixes to session verification API breaks. * Update forced logout dialog message, remove `NativeSlidingSyncMigrationBanner` * Update screenshots * Update all strings * Remove `SuccessfulLogoutPendingAction` --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín <[email protected]> Co-authored-by: ElementBot <[email protected]>
1 parent e128eca commit beffba1

File tree

95 files changed

+103
-532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+103
-532
lines changed

appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
7575
import io.element.android.libraries.matrix.api.permalink.PermalinkData
7676
import io.element.android.libraries.matrix.api.verification.SessionVerificationRequestDetails
7777
import io.element.android.libraries.matrix.api.verification.SessionVerificationServiceListener
78-
import io.element.android.libraries.preferences.api.store.EnableNativeSlidingSyncUseCase
7978
import io.element.android.services.appnavstate.api.AppNavigationStateService
8079
import kotlinx.coroutines.CoroutineScope
8180
import kotlinx.coroutines.flow.launchIn
@@ -105,7 +104,6 @@ class LoggedInFlowNode @AssistedInject constructor(
105104
private val sendingQueue: SendQueues,
106105
private val logoutEntryPoint: LogoutEntryPoint,
107106
private val incomingVerificationEntryPoint: IncomingVerificationEntryPoint,
108-
private val enableNativeSlidingSyncUseCase: EnableNativeSlidingSyncUseCase,
109107
snackbarDispatcher: SnackbarDispatcher,
110108
) : BaseFlowNode<LoggedInFlowNode.NavTarget>(
111109
backstack = BackStack(
@@ -420,9 +418,6 @@ class LoggedInFlowNode @AssistedInject constructor(
420418
}
421419

422420
logoutEntryPoint.nodeBuilder(this, buildContext)
423-
.onSuccessfulLogoutPendingAction {
424-
enableNativeSlidingSyncUseCase()
425-
}
426421
.callback(callback)
427422
.build()
428423
}

appnav/src/main/kotlin/io/element/android/appnav/loggedin/LoggedInPresenter.kt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import im.vector.app.features.analytics.plan.UserProperties
2222
import io.element.android.libraries.architecture.AsyncData
2323
import io.element.android.libraries.architecture.Presenter
2424
import io.element.android.libraries.core.log.logger.LoggerTag
25+
import io.element.android.libraries.core.meta.BuildMeta
2526
import io.element.android.libraries.matrix.api.MatrixClient
2627
import io.element.android.libraries.matrix.api.encryption.EncryptionService
2728
import io.element.android.libraries.matrix.api.encryption.RecoveryState
@@ -31,7 +32,6 @@ import io.element.android.libraries.matrix.api.sync.SyncService
3132
import io.element.android.libraries.matrix.api.sync.isOnline
3233
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
3334
import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatus
34-
import io.element.android.libraries.preferences.api.store.EnableNativeSlidingSyncUseCase
3535
import io.element.android.libraries.push.api.PushService
3636
import io.element.android.libraries.pushproviders.api.RegistrationFailure
3737
import io.element.android.services.analytics.api.AnalyticsService
@@ -51,7 +51,7 @@ class LoggedInPresenter @Inject constructor(
5151
private val sessionVerificationService: SessionVerificationService,
5252
private val analyticsService: AnalyticsService,
5353
private val encryptionService: EncryptionService,
54-
private val enableNativeSlidingSyncUseCase: EnableNativeSlidingSyncUseCase,
54+
private val buildMeta: BuildMeta,
5555
) : Presenter<LoggedInState> {
5656
@Composable
5757
override fun present(): LoggedInState {
@@ -103,12 +103,10 @@ class LoggedInPresenter @Inject constructor(
103103
}
104104
}
105105
LoggedInEvents.CheckSlidingSyncProxyAvailability -> coroutineScope.launch {
106-
forceNativeSlidingSyncMigration = matrixClient.forceNativeSlidingSyncMigration().getOrDefault(false)
106+
forceNativeSlidingSyncMigration = matrixClient.needsForcedNativeSlidingSyncMigration().getOrDefault(false)
107107
}
108108
LoggedInEvents.LogoutAndMigrateToNativeSlidingSync -> coroutineScope.launch {
109-
// Enable native sliding sync if it wasn't already the case
110-
enableNativeSlidingSyncUseCase()
111-
// Then force the logout
109+
// Force the logout since Native Sliding Sync is already enforced by the SDK
112110
matrixClient.logout(userInitiated = true, ignoreSdkError = true)
113111
}
114112
}
@@ -119,20 +117,15 @@ class LoggedInPresenter @Inject constructor(
119117
pusherRegistrationState = pusherRegistrationState.value,
120118
ignoreRegistrationError = ignoreRegistrationError,
121119
forceNativeSlidingSyncMigration = forceNativeSlidingSyncMigration,
120+
appName = buildMeta.applicationName,
122121
eventSink = ::handleEvent
123122
)
124123
}
125124

126-
// Force the user to log out if they were using the proxy sliding sync and it's no longer available, but native sliding sync is.
127-
private suspend fun MatrixClient.forceNativeSlidingSyncMigration(): Result<Boolean> = runCatching {
125+
// Force the user to log out if they were using the proxy sliding sync as it's no longer supported by the SDK
126+
private suspend fun MatrixClient.needsForcedNativeSlidingSyncMigration(): Result<Boolean> = runCatching {
128127
val currentSlidingSyncVersion = currentSlidingSyncVersion().getOrThrow()
129-
if (currentSlidingSyncVersion == SlidingSyncVersion.Proxy) {
130-
val availableSlidingSyncVersions = availableSlidingSyncVersions().getOrThrow()
131-
availableSlidingSyncVersions.contains(SlidingSyncVersion.Native) &&
132-
!availableSlidingSyncVersions.contains(SlidingSyncVersion.Proxy)
133-
} else {
134-
false
135-
}
128+
currentSlidingSyncVersion == SlidingSyncVersion.Proxy
136129
}
137130

138131
private suspend fun ensurePusherIsRegistered(pusherRegistrationState: MutableState<AsyncData<Unit>>) {

appnav/src/main/kotlin/io/element/android/appnav/loggedin/LoggedInState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ data class LoggedInState(
1414
val pusherRegistrationState: AsyncData<Unit>,
1515
val ignoreRegistrationError: Boolean,
1616
val forceNativeSlidingSyncMigration: Boolean,
17+
val appName: String,
1718
val eventSink: (LoggedInEvents) -> Unit,
1819
)

appnav/src/main/kotlin/io/element/android/appnav/loggedin/LoggedInStateProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ fun aLoggedInState(
2424
showSyncSpinner: Boolean = false,
2525
pusherRegistrationState: AsyncData<Unit> = AsyncData.Uninitialized,
2626
forceNativeSlidingSyncMigration: Boolean = false,
27+
appName: String = "Element X",
2728
) = LoggedInState(
2829
showSyncSpinner = showSyncSpinner,
2930
pusherRegistrationState = pusherRegistrationState,
3031
ignoreRegistrationError = false,
3132
forceNativeSlidingSyncMigration = forceNativeSlidingSyncMigration,
33+
appName = appName,
3234
eventSink = {},
3335
)

appnav/src/main/kotlin/io/element/android/appnav/loggedin/LoggedInView.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ fun LoggedInView(
7373

7474
// Set the force migration dialog here so it's always displayed over every screen
7575
if (state.forceNativeSlidingSyncMigration) {
76-
ForceNativeSlidingSyncMigrationDialog(onSubmit = {
77-
state.eventSink(LoggedInEvents.LogoutAndMigrateToNativeSlidingSync)
78-
})
76+
ForceNativeSlidingSyncMigrationDialog(
77+
appName = state.appName,
78+
onSubmit = {
79+
state.eventSink(LoggedInEvents.LogoutAndMigrateToNativeSlidingSync)
80+
}
81+
)
7982
}
8083
}
8184

@@ -98,11 +101,12 @@ private fun Throwable.getReason(): String? {
98101

99102
@Composable
100103
private fun ForceNativeSlidingSyncMigrationDialog(
104+
appName: String,
101105
onSubmit: () -> Unit,
102106
) {
103107
ErrorDialog(
104108
title = null,
105-
content = stringResource(R.string.banner_migrate_to_native_sliding_sync_force_logout_title),
109+
content = stringResource(R.string.banner_migrate_to_native_sliding_sync_app_force_logout_title, appName),
106110
submitText = stringResource(R.string.banner_migrate_to_native_sliding_sync_action),
107111
onSubmit = onSubmit,
108112
canDismiss = false,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
33
<string name="banner_migrate_to_native_sliding_sync_action">"Log Out &amp; Upgrade"</string>
4+
<string name="banner_migrate_to_native_sliding_sync_app_force_logout_title">"%1$s no longer supports the old protocol. Please log out and log back in to continue using the app."</string>
45
<string name="banner_migrate_to_native_sliding_sync_force_logout_title">"Your homeserver no longer supports the old protocol. Please log out and log back in to continue using the app."</string>
56
</resources>

appnav/src/test/kotlin/io/element/android/appnav/loggedin/LoggedInPresenterTest.kt

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import app.cash.turbine.test
1414
import com.google.common.truth.Truth.assertThat
1515
import im.vector.app.features.analytics.plan.CryptoSessionStateChange
1616
import im.vector.app.features.analytics.plan.UserProperties
17+
import io.element.android.libraries.core.meta.BuildMeta
1718
import io.element.android.libraries.matrix.api.MatrixClient
1819
import io.element.android.libraries.matrix.api.core.SessionId
1920
import io.element.android.libraries.matrix.api.encryption.EncryptionService
@@ -26,12 +27,11 @@ import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatu
2627
import io.element.android.libraries.matrix.test.AN_EXCEPTION
2728
import io.element.android.libraries.matrix.test.A_SESSION_ID
2829
import io.element.android.libraries.matrix.test.FakeMatrixClient
30+
import io.element.android.libraries.matrix.test.core.aBuildMeta
2931
import io.element.android.libraries.matrix.test.encryption.FakeEncryptionService
3032
import io.element.android.libraries.matrix.test.roomlist.FakeRoomListService
3133
import io.element.android.libraries.matrix.test.sync.FakeSyncService
3234
import io.element.android.libraries.matrix.test.verification.FakeSessionVerificationService
33-
import io.element.android.libraries.preferences.api.store.EnableNativeSlidingSyncUseCase
34-
import io.element.android.libraries.preferences.test.InMemoryAppPreferencesStore
3535
import io.element.android.libraries.push.api.PushService
3636
import io.element.android.libraries.push.test.FakePushService
3737
import io.element.android.libraries.pushproviders.api.Distributor
@@ -46,7 +46,6 @@ import io.element.android.tests.testutils.lambda.lambdaError
4646
import io.element.android.tests.testutils.lambda.lambdaRecorder
4747
import io.element.android.tests.testutils.lambda.value
4848
import kotlinx.coroutines.ExperimentalCoroutinesApi
49-
import kotlinx.coroutines.flow.first
5049
import kotlinx.coroutines.test.TestScope
5150
import kotlinx.coroutines.test.advanceUntilIdle
5251
import kotlinx.coroutines.test.runTest
@@ -92,14 +91,15 @@ class LoggedInPresenterTest {
9291
val roomListService = FakeRoomListService()
9392
val verificationService = FakeSessionVerificationService()
9493
val encryptionService = FakeEncryptionService()
94+
val buildMeta = aBuildMeta()
9595
val presenter = LoggedInPresenter(
9696
matrixClient = FakeMatrixClient(roomListService = roomListService, encryptionService = encryptionService),
9797
syncService = FakeSyncService(initialSyncState = SyncState.Running),
9898
pushService = FakePushService(),
9999
sessionVerificationService = verificationService,
100100
analyticsService = analyticsService,
101101
encryptionService = encryptionService,
102-
enableNativeSlidingSyncUseCase = EnableNativeSlidingSyncUseCase(InMemoryAppPreferencesStore(), this),
102+
buildMeta = buildMeta,
103103
)
104104
moleculeFlow(RecompositionMode.Immediate) {
105105
presenter.present()
@@ -518,28 +518,9 @@ class LoggedInPresenterTest {
518518
}
519519
}
520520

521-
@Test
522-
fun `present - CheckSlidingSyncProxyAvailability will not force the migration if native sliding sync is not supported too`() = runTest {
523-
val matrixClient = FakeMatrixClient(
524-
currentSlidingSyncVersionLambda = { Result.success(SlidingSyncVersion.Proxy) },
525-
availableSlidingSyncVersionsLambda = { Result.success(emptyList()) },
526-
)
527-
val presenter = createLoggedInPresenter(matrixClient = matrixClient)
528-
moleculeFlow(RecompositionMode.Immediate) {
529-
presenter.present()
530-
}.test {
531-
val initialState = awaitItem()
532-
assertThat(initialState.forceNativeSlidingSyncMigration).isFalse()
533-
534-
initialState.eventSink(LoggedInEvents.CheckSlidingSyncProxyAvailability)
535-
536-
expectNoEvents()
537-
}
538-
}
539-
540521
@OptIn(ExperimentalCoroutinesApi::class)
541522
@Test
542-
fun `present - LogoutAndMigrateToNativeSlidingSync enables native sliding sync and logs out the user`() = runTest {
523+
fun `present - LogoutAndMigrateToNativeSlidingSync logs out the user`() = runTest {
543524
val logoutLambda = lambdaRecorder<Boolean, Boolean, String?> { userInitiated, ignoreSdkError ->
544525
assertThat(userInitiated).isTrue()
545526
assertThat(ignoreSdkError).isTrue()
@@ -548,21 +529,16 @@ class LoggedInPresenterTest {
548529
val matrixClient = FakeMatrixClient().apply {
549530
this.logoutLambda = logoutLambda
550531
}
551-
val appPreferencesStore = InMemoryAppPreferencesStore()
552-
val enableNativeSlidingSyncUseCase = EnableNativeSlidingSyncUseCase(appPreferencesStore, this)
553-
val presenter = createLoggedInPresenter(matrixClient = matrixClient, enableNativeSlidingSyncUseCase = enableNativeSlidingSyncUseCase)
532+
val presenter = createLoggedInPresenter(matrixClient = matrixClient)
554533
moleculeFlow(RecompositionMode.Immediate) {
555534
presenter.present()
556535
}.test {
557536
val initialState = awaitItem()
558537

559-
assertThat(appPreferencesStore.isSimplifiedSlidingSyncEnabledFlow().first()).isFalse()
560-
561538
initialState.eventSink(LoggedInEvents.LogoutAndMigrateToNativeSlidingSync)
562539

563540
advanceUntilIdle()
564541

565-
assertThat(appPreferencesStore.isSimplifiedSlidingSyncEnabledFlow().first()).isTrue()
566542
assertThat(logoutLambda.assertions().isCalledOnce())
567543
}
568544
}
@@ -579,8 +555,8 @@ class LoggedInPresenterTest {
579555
sessionVerificationService: SessionVerificationService = FakeSessionVerificationService(),
580556
encryptionService: EncryptionService = FakeEncryptionService(),
581557
pushService: PushService = FakePushService(),
582-
enableNativeSlidingSyncUseCase: EnableNativeSlidingSyncUseCase = EnableNativeSlidingSyncUseCase(InMemoryAppPreferencesStore(), this),
583558
matrixClient: MatrixClient = FakeMatrixClient(roomListService = roomListService),
559+
buildMeta: BuildMeta = aBuildMeta(),
584560
): LoggedInPresenter {
585561
return LoggedInPresenter(
586562
matrixClient = matrixClient,
@@ -589,7 +565,7 @@ class LoggedInPresenterTest {
589565
sessionVerificationService = sessionVerificationService,
590566
analyticsService = analyticsService,
591567
encryptionService = encryptionService,
592-
enableNativeSlidingSyncUseCase = enableNativeSlidingSyncUseCase,
568+
buildMeta = buildMeta,
593569
)
594570
}
595571
}

features/logout/api/src/main/kotlin/io/element/android/features/logout/api/LogoutEntryPoint.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ interface LogoutEntryPoint : FeatureEntryPoint {
1616
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder
1717

1818
interface NodeBuilder {
19-
fun onSuccessfulLogoutPendingAction(action: () -> Unit): NodeBuilder
2019
fun callback(callback: Callback): NodeBuilder
2120
fun build(): Node
2221
}

features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/DefaultLogoutEntryPoint.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ class DefaultLogoutEntryPoint @Inject constructor() : LogoutEntryPoint {
2727
return this
2828
}
2929

30-
override fun onSuccessfulLogoutPendingAction(action: () -> Unit): LogoutEntryPoint.NodeBuilder {
31-
plugins += object : LogoutNode.SuccessfulLogoutPendingAction, Plugin {
32-
override fun onSuccessfulLogoutPendingAction() {
33-
action()
34-
}
35-
}
36-
return this
37-
}
38-
3930
override fun build(): Node {
4031
return parentNode.createNode<LogoutNode>(buildContext, plugins)
4132
}

features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutNode.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ class LogoutNode @AssistedInject constructor(
3232
plugins<LogoutEntryPoint.Callback>().forEach { it.onChangeRecoveryKeyClick() }
3333
}
3434

35-
interface SuccessfulLogoutPendingAction : Plugin {
36-
fun onSuccessfulLogoutPendingAction()
37-
}
38-
39-
private val customOnSuccessfulLogoutPendingAction = plugins<SuccessfulLogoutPendingAction>().firstOrNull()
40-
4135
@Composable
4236
override fun View(modifier: Modifier) {
4337
val state = presenter.present()
@@ -47,7 +41,6 @@ class LogoutNode @AssistedInject constructor(
4741
state = state,
4842
onChangeRecoveryKeyClick = ::onChangeRecoveryKeyClick,
4943
onSuccessLogout = {
50-
customOnSuccessfulLogoutPendingAction?.onSuccessfulLogoutPendingAction()
5144
onSuccessLogout(activity, isDark, it)
5245
},
5346
onBackClick = ::navigateUp,

0 commit comments

Comments
 (0)