Skip to content

Commit dbb1de1

Browse files
authored
Upgrade SDK version to 25.02.26 (#4305)
* Upgrade SDK version to 25.02.26 * Remove OIDC URL result from logout, the SDK no longer provides it * Handle room creation and destruction in a better way * Remove `onSuccessLogout`
1 parent efb5acc commit dbb1de1

File tree

40 files changed

+46
-230
lines changed

40 files changed

+46
-230
lines changed

appnav/src/main/kotlin/io/element/android/appnav/room/joined/JoinedRoomLoadedFlowNode.kt

+1-13
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ package io.element.android.appnav.room.joined
99

1010
import android.os.Parcelable
1111
import androidx.compose.runtime.Composable
12-
import androidx.compose.runtime.DisposableEffect
1312
import androidx.compose.ui.Modifier
14-
import androidx.lifecycle.Lifecycle
1513
import androidx.lifecycle.lifecycleScope
1614
import com.bumble.appyx.core.lifecycle.subscribe
1715
import com.bumble.appyx.core.modality.BuildContext
@@ -56,7 +54,7 @@ class JoinedRoomLoadedFlowNode @AssistedInject constructor(
5654
roomComponentFactory: RoomComponentFactory,
5755
) : BaseFlowNode<JoinedRoomLoadedFlowNode.NavTarget>(
5856
backstack = BackStack(
59-
initialElement = when (val input = plugins.filterIsInstance(Inputs::class.java).first().initialElement) {
57+
initialElement = when (val input = plugins.filterIsInstance<Inputs>().first().initialElement) {
6058
is RoomNavigationTarget.Messages -> NavTarget.Messages(input.focusedEventId)
6159
RoomNavigationTarget.Details -> NavTarget.RoomDetails
6260
RoomNavigationTarget.NotificationSettings -> NavTarget.RoomNotificationSettings
@@ -197,16 +195,6 @@ class JoinedRoomLoadedFlowNode @AssistedInject constructor(
197195

198196
@Composable
199197
override fun View(modifier: Modifier) {
200-
// Rely on the View Lifecycle in addition to the Node Lifecycle,
201-
// because this node enters 'onDestroy' before his children, so it can leads to
202-
// using the room in a child node where it's already closed.
203-
DisposableEffect(Unit) {
204-
onDispose {
205-
if (lifecycle.currentState == Lifecycle.State.DESTROYED) {
206-
inputs.room.destroy()
207-
}
208-
}
209-
}
210198
BackstackView()
211199
}
212200
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,9 @@ class LoggedInPresenterTest {
521521
@OptIn(ExperimentalCoroutinesApi::class)
522522
@Test
523523
fun `present - LogoutAndMigrateToNativeSlidingSync logs out the user`() = runTest {
524-
val logoutLambda = lambdaRecorder<Boolean, Boolean, String?> { userInitiated, ignoreSdkError ->
524+
val logoutLambda = lambdaRecorder<Boolean, Boolean, Unit> { userInitiated, ignoreSdkError ->
525525
assertThat(userInitiated).isTrue()
526526
assertThat(ignoreSdkError).isTrue()
527-
null
528527
}
529528
val matrixClient = FakeMatrixClient().apply {
530529
this.logoutLambda = logoutLambda

features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockNode.kt

-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package io.element.android.features.lockscreen.impl.unlock
99

10-
import androidx.activity.compose.LocalActivity
1110
import androidx.compose.runtime.Composable
1211
import androidx.compose.runtime.LaunchedEffect
1312
import androidx.compose.ui.Modifier
@@ -18,8 +17,6 @@ import com.bumble.appyx.core.plugin.plugins
1817
import dagger.assisted.Assisted
1918
import dagger.assisted.AssistedInject
2019
import io.element.android.anvilannotations.ContributesNode
21-
import io.element.android.compound.theme.ElementTheme
22-
import io.element.android.features.logout.api.util.onSuccessLogout
2320
import io.element.android.libraries.di.SessionScope
2421

2522
@ContributesNode(SessionScope::class)
@@ -41,8 +38,6 @@ class PinUnlockNode @AssistedInject constructor(
4138
@Composable
4239
override fun View(modifier: Modifier) {
4340
val state = presenter.present()
44-
val activity = requireNotNull(LocalActivity.current)
45-
val isDark = ElementTheme.isLightTheme.not()
4641
LaunchedEffect(state.isUnlocked) {
4742
if (state.isUnlocked) {
4843
onUnlock()
@@ -53,7 +48,6 @@ class PinUnlockNode @AssistedInject constructor(
5348
// UnlockNode is only used for in-app unlock, so we can safely set isInAppUnlock to true.
5449
// It's set to false in PinUnlockActivity.
5550
isInAppUnlock = true,
56-
onSuccessLogout = { onSuccessLogout(activity, isDark, it) },
5751
modifier = modifier
5852
)
5953
}

features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockPresenter.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PinUnlockPresenter @Inject constructor(
5353
mutableStateOf(false)
5454
}
5555
val signOutAction = remember {
56-
mutableStateOf<AsyncAction<String?>>(AsyncAction.Uninitialized)
56+
mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized)
5757
}
5858
var biometricUnlockResult by remember {
5959
mutableStateOf<BiometricAuthenticator.AuthenticationResult?>(null)
@@ -169,7 +169,7 @@ class PinUnlockPresenter @Inject constructor(
169169
}
170170
}
171171

172-
private fun CoroutineScope.signOut(signOutAction: MutableState<AsyncAction<String?>>) = launch {
172+
private fun CoroutineScope.signOut(signOutAction: MutableState<AsyncAction<Unit>>) = launch {
173173
suspend {
174174
logoutUseCase.logout(ignoreSdkError = true)
175175
}.runCatchingUpdatingState(signOutAction)

features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockState.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data class PinUnlockState(
1818
val showWrongPinTitle: Boolean,
1919
val remainingAttempts: AsyncData<Int>,
2020
val showSignOutPrompt: Boolean,
21-
val signOutAction: AsyncAction<String?>,
21+
val signOutAction: AsyncAction<Unit>,
2222
val showBiometricUnlock: Boolean,
2323
val isUnlocked: Boolean,
2424
val biometricUnlockResult: BiometricAuthenticator.AuthenticationResult?,

features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockStateProvider.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fun aPinUnlockState(
4141
showBiometricUnlock: Boolean = true,
4242
biometricUnlockResult: BiometricAuthenticator.AuthenticationResult? = null,
4343
isUnlocked: Boolean = false,
44-
signOutAction: AsyncAction<String?> = AsyncAction.Uninitialized,
44+
signOutAction: AsyncAction<Unit> = AsyncAction.Uninitialized,
4545
) = PinUnlockState(
4646
pinEntry = AsyncData.Success(pinEntry),
4747
showWrongPinTitle = showWrongPinTitle,

features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockView.kt

+1-11
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ import androidx.compose.material.icons.Icons
2929
import androidx.compose.material.icons.filled.Lock
3030
import androidx.compose.runtime.Composable
3131
import androidx.compose.runtime.LaunchedEffect
32-
import androidx.compose.runtime.getValue
3332
import androidx.compose.runtime.remember
34-
import androidx.compose.runtime.rememberUpdatedState
3533
import androidx.compose.ui.Alignment
3634
import androidx.compose.ui.Modifier
3735
import androidx.compose.ui.focus.FocusRequester
@@ -67,7 +65,6 @@ import io.element.android.libraries.ui.strings.CommonStrings
6765
fun PinUnlockView(
6866
state: PinUnlockState,
6967
isInAppUnlock: Boolean,
70-
onSuccessLogout: (logoutUrlResult: String?) -> Unit,
7168
modifier: Modifier = Modifier,
7269
) {
7370
OnLifecycleEvent { _, event ->
@@ -89,12 +86,7 @@ fun PinUnlockView(
8986
AsyncAction.Loading -> {
9087
ProgressDialog(text = stringResource(id = R.string.screen_signout_in_progress_dialog_content))
9188
}
92-
is AsyncAction.Success -> {
93-
val latestOnSuccessLogout by rememberUpdatedState(onSuccessLogout)
94-
LaunchedEffect(state) {
95-
latestOnSuccessLogout(state.signOutAction.data)
96-
}
97-
}
89+
is AsyncAction.Success,
9890
is AsyncAction.Confirming,
9991
is AsyncAction.Failure,
10092
AsyncAction.Uninitialized -> Unit
@@ -369,7 +361,6 @@ internal fun PinUnlockViewInAppPreview(@PreviewParameter(PinUnlockStateProvider:
369361
PinUnlockView(
370362
state = state,
371363
isInAppUnlock = true,
372-
onSuccessLogout = {},
373364
)
374365
}
375366
}
@@ -381,7 +372,6 @@ internal fun PinUnlockViewPreview(@PreviewParameter(PinUnlockStateProvider::clas
381372
PinUnlockView(
382373
state = state,
383374
isInAppUnlock = false,
384-
onSuccessLogout = {},
385375
)
386376
}
387377
}

features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/activity/PinUnlockActivity.kt

-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ import androidx.activity.compose.setContent
1515
import androidx.activity.enableEdgeToEdge
1616
import androidx.appcompat.app.AppCompatActivity
1717
import androidx.lifecycle.lifecycleScope
18-
import io.element.android.compound.theme.ElementTheme
1918
import io.element.android.features.enterprise.api.EnterpriseService
2019
import io.element.android.features.lockscreen.api.LockScreenLockState
2120
import io.element.android.features.lockscreen.api.LockScreenService
2221
import io.element.android.features.lockscreen.impl.unlock.PinUnlockPresenter
2322
import io.element.android.features.lockscreen.impl.unlock.PinUnlockView
2423
import io.element.android.features.lockscreen.impl.unlock.di.PinUnlockBindings
25-
import io.element.android.features.logout.api.util.onSuccessLogout
2624
import io.element.android.libraries.architecture.bindings
2725
import io.element.android.libraries.designsystem.theme.ElementThemeApp
2826
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
@@ -51,11 +49,9 @@ class PinUnlockActivity : AppCompatActivity() {
5149
enterpriseService = enterpriseService,
5250
) {
5351
val state = presenter.present()
54-
val isDark = ElementTheme.isLightTheme.not()
5552
PinUnlockView(
5653
state = state,
5754
isInAppUnlock = false,
58-
onSuccessLogout = { onSuccessLogout(this, isDark, it) },
5955
)
6056
}
6157
}

features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockPresenterTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class PinUnlockPresenterTest {
9898

9999
@Test
100100
fun `present - forgot pin flow`() = runTest {
101-
val signOutLambda = lambdaRecorder<Boolean, String?> { "" }
101+
val signOutLambda = lambdaRecorder<Boolean, Unit> {}
102102
val signOut = FakeLogoutUseCase(signOutLambda)
103103
val presenter = createPinUnlockPresenter(this, logoutUseCase = signOut)
104104
moleculeFlow(RecompositionMode.Immediate) {

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ interface LogoutUseCase {
1414
/**
1515
* Log out the current user and then perform any needed cleanup tasks.
1616
* @param ignoreSdkError if true, the SDK error will be ignored and the user will be logged out anyway.
17-
* @return an optional URL. When the URL is there, it should be presented to the user after logout for
18-
* Relying Party (RP) initiated logout on their account page.
1917
*/
20-
suspend fun logout(ignoreSdkError: Boolean): String?
18+
suspend fun logout(ignoreSdkError: Boolean)
2119

2220
interface Factory {
2321
fun create(sessionId: String): LogoutUseCase

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import io.element.android.libraries.architecture.AsyncAction
1111

1212
data class DirectLogoutState(
1313
val canDoDirectSignOut: Boolean,
14-
val logoutAction: AsyncAction<String?>,
14+
val logoutAction: AsyncAction<Unit>,
1515
val eventSink: (DirectLogoutEvents) -> Unit,
1616
)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ open class DirectLogoutStateProvider : PreviewParameterProvider<DirectLogoutStat
1717
aDirectLogoutState(logoutAction = AsyncAction.ConfirmingNoParams),
1818
aDirectLogoutState(logoutAction = AsyncAction.Loading),
1919
aDirectLogoutState(logoutAction = AsyncAction.Failure(Exception("Error"))),
20-
aDirectLogoutState(logoutAction = AsyncAction.Success("success")),
20+
aDirectLogoutState(logoutAction = AsyncAction.Success(Unit)),
2121
)
2222
}
2323

2424
fun aDirectLogoutState(
2525
canDoDirectSignOut: Boolean = true,
26-
logoutAction: AsyncAction<String?> = AsyncAction.Uninitialized,
26+
logoutAction: AsyncAction<Unit> = AsyncAction.Uninitialized,
2727
eventSink: (DirectLogoutEvents) -> Unit = {},
2828
) = DirectLogoutState(
2929
canDoDirectSignOut = canDoDirectSignOut,

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,5 @@ import androidx.compose.runtime.Composable
1111

1212
interface DirectLogoutView {
1313
@Composable
14-
fun Render(
15-
state: DirectLogoutState,
16-
onSuccessLogout: (logoutUrlResult: String?) -> Unit
17-
)
14+
fun Render(state: DirectLogoutState)
1815
}

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

-23
This file was deleted.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class DefaultLogoutUseCase @Inject constructor(
1919
private val authenticationService: MatrixAuthenticationService,
2020
private val matrixClientProvider: MatrixClientProvider,
2121
) : LogoutUseCase {
22-
override suspend fun logout(ignoreSdkError: Boolean): String? {
22+
override suspend fun logout(ignoreSdkError: Boolean) {
2323
val currentSession = authenticationService.getLatestSessionId()
24-
return if (currentSession != null) {
24+
if (currentSession != null) {
2525
matrixClientProvider.getOrRestore(currentSession)
2626
.getOrThrow()
2727
.logout(userInitiated = true, ignoreSdkError = true)

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

-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package io.element.android.features.logout.impl
99

10-
import androidx.activity.compose.LocalActivity
1110
import androidx.compose.runtime.Composable
1211
import androidx.compose.ui.Modifier
1312
import com.bumble.appyx.core.modality.BuildContext
@@ -17,9 +16,7 @@ import com.bumble.appyx.core.plugin.plugins
1716
import dagger.assisted.Assisted
1817
import dagger.assisted.AssistedInject
1918
import io.element.android.anvilannotations.ContributesNode
20-
import io.element.android.compound.theme.ElementTheme
2119
import io.element.android.features.logout.api.LogoutEntryPoint
22-
import io.element.android.features.logout.api.util.onSuccessLogout
2320
import io.element.android.libraries.di.SessionScope
2421

2522
@ContributesNode(SessionScope::class)
@@ -35,14 +32,9 @@ class LogoutNode @AssistedInject constructor(
3532
@Composable
3633
override fun View(modifier: Modifier) {
3734
val state = presenter.present()
38-
val activity = requireNotNull(LocalActivity.current)
39-
val isDark = ElementTheme.isLightTheme.not()
4035
LogoutView(
4136
state = state,
4237
onChangeRecoveryKeyClick = ::onChangeRecoveryKeyClick,
43-
onSuccessLogout = {
44-
onSuccessLogout(activity, isDark, it)
45-
},
4638
onBackClick = ::navigateUp,
4739
modifier = modifier,
4840
)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class LogoutPresenter @Inject constructor(
3535
@Composable
3636
override fun present(): LogoutState {
3737
val localCoroutineScope = rememberCoroutineScope()
38-
val logoutAction: MutableState<AsyncAction<String?>> = remember {
38+
val logoutAction: MutableState<AsyncAction<Unit>> = remember {
3939
mutableStateOf(AsyncAction.Uninitialized)
4040
}
4141

@@ -91,7 +91,7 @@ class LogoutPresenter @Inject constructor(
9191
}
9292

9393
private fun CoroutineScope.logout(
94-
logoutAction: MutableState<AsyncAction<String?>>,
94+
logoutAction: MutableState<AsyncAction<Unit>>,
9595
ignoreSdkError: Boolean,
9696
) = launch {
9797
suspend {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ data class LogoutState(
1818
val doesBackupExistOnServer: Boolean,
1919
val recoveryState: RecoveryState,
2020
val backupUploadState: BackupUploadState,
21-
val logoutAction: AsyncAction<String?>,
21+
val logoutAction: AsyncAction<Unit>,
2222
val eventSink: (LogoutEvents) -> Unit,
2323
)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fun aLogoutState(
3838
doesBackupExistOnServer: Boolean = true,
3939
recoveryState: RecoveryState = RecoveryState.ENABLED,
4040
backupUploadState: BackupUploadState = BackupUploadState.Unknown,
41-
logoutAction: AsyncAction<String?> = AsyncAction.Uninitialized,
41+
logoutAction: AsyncAction<Unit> = AsyncAction.Uninitialized,
4242
eventSink: (LogoutEvents) -> Unit = {},
4343
) = LogoutState(
4444
isLastDevice = isLastDevice,

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

-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ fun LogoutView(
4545
state: LogoutState,
4646
onChangeRecoveryKeyClick: () -> Unit,
4747
onBackClick: () -> Unit,
48-
onSuccessLogout: (logoutUrlResult: String?) -> Unit,
4948
modifier: Modifier = Modifier,
5049
) {
5150
val eventSink = state.eventSink
@@ -80,9 +79,6 @@ fun LogoutView(
8079
onDismissDialog = {
8180
eventSink(LogoutEvents.CloseDialogs)
8281
},
83-
onSuccessLogout = {
84-
onSuccessLogout(it)
85-
},
8682
)
8783
}
8884

@@ -177,7 +173,6 @@ internal fun LogoutViewPreview(
177173
LogoutView(
178174
state,
179175
onChangeRecoveryKeyClick = {},
180-
onSuccessLogout = {},
181176
onBackClick = {},
182177
)
183178
}

0 commit comments

Comments
 (0)