Skip to content

Commit da03a50

Browse files
authored
Merge pull request #5237 from element-hq/feature/bma/removeLoginUserStory
Remove LoginUserStory.
2 parents f4708a4 + 1632706 commit da03a50

File tree

13 files changed

+6
-119
lines changed

13 files changed

+6
-119
lines changed

appnav/src/main/kotlin/io/element/android/appnav/root/RootNavStateFlowFactory.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ package io.element.android.appnav.root
1010
import com.bumble.appyx.core.state.MutableSavedStateMap
1111
import com.bumble.appyx.core.state.SavedStateMap
1212
import io.element.android.appnav.di.MatrixSessionCache
13-
import io.element.android.features.login.api.LoginUserStory
1413
import io.element.android.features.preferences.api.CacheService
1514
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
1615
import io.element.android.libraries.matrix.ui.media.ImageLoaderHolder
1716
import io.element.android.libraries.preferences.api.store.SessionPreferencesStoreFactory
18-
import io.element.android.libraries.sessionstorage.api.LoggedInState
1917
import kotlinx.coroutines.flow.Flow
2018
import kotlinx.coroutines.flow.combine
2119
import kotlinx.coroutines.flow.flow
@@ -33,7 +31,6 @@ class RootNavStateFlowFactory @Inject constructor(
3331
private val cacheService: CacheService,
3432
private val matrixSessionCache: MatrixSessionCache,
3533
private val imageLoaderHolder: ImageLoaderHolder,
36-
private val loginUserStory: LoginUserStory,
3734
private val sessionPreferencesStoreFactory: SessionPreferencesStoreFactory,
3835
) {
3936
private var currentCacheIndex = 0
@@ -42,13 +39,11 @@ class RootNavStateFlowFactory @Inject constructor(
4239
return combine(
4340
cacheIndexFlow(savedStateMap),
4441
authenticationService.loggedInStateFlow(),
45-
loginUserStory.loginFlowIsDone,
46-
) { cacheIndex, loggedInState, loginFlowIsDone ->
47-
if (loginFlowIsDone) {
48-
RootNavState(cacheIndex = cacheIndex, loggedInState = loggedInState)
49-
} else {
50-
RootNavState(cacheIndex = cacheIndex, loggedInState = LoggedInState.NotLoggedIn)
51-
}
42+
) { cacheIndex, loggedInState ->
43+
RootNavState(
44+
cacheIndex = cacheIndex,
45+
loggedInState = loggedInState,
46+
)
5247
}
5348
}
5449

features/login/api/src/main/kotlin/io/element/android/features/login/api/LoginUserStory.kt

Lines changed: 0 additions & 14 deletions
This file was deleted.

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/DefaultLoginUserStory.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/LoginFlowNode.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class LoginFlowNode @AssistedInject constructor(
5555
@Assisted buildContext: BuildContext,
5656
@Assisted plugins: List<Plugin>,
5757
private val accountProviderDataSource: AccountProviderDataSource,
58-
private val defaultLoginUserStory: DefaultLoginUserStory,
5958
private val oidcActionFlow: OidcActionFlow,
6059
) : BaseFlowNode<LoginFlowNode.NavTarget>(
6160
backstack = BackStack(
@@ -77,7 +76,6 @@ class LoginFlowNode @AssistedInject constructor(
7776

7877
override fun onBuilt() {
7978
super.onBuilt()
80-
defaultLoginUserStory.setLoginFlowIsDone(false)
8179
lifecycle.subscribe(
8280
onResume = {
8381
if (externalAppStarted) {

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/login/LoginHelper.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import androidx.compose.runtime.LaunchedEffect
1212
import androidx.compose.runtime.MutableState
1313
import androidx.compose.runtime.State
1414
import androidx.compose.runtime.mutableStateOf
15-
import io.element.android.features.login.impl.DefaultLoginUserStory
1615
import io.element.android.features.login.impl.error.ChangeServerError
1716
import io.element.android.features.login.impl.screens.chooseaccountprovider.ChooseAccountProviderPresenter
1817
import io.element.android.features.login.impl.screens.confirmaccountprovider.ConfirmAccountProviderPresenter
@@ -38,7 +37,6 @@ import javax.inject.Inject
3837
class LoginHelper @Inject constructor(
3938
private val oidcActionFlow: OidcActionFlow,
4039
private val authenticationService: MatrixAuthenticationService,
41-
private val defaultLoginUserStory: DefaultLoginUserStory,
4240
private val webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever,
4341
) {
4442
private val loginModeState: MutableState<AsyncData<LoginMode>> = mutableStateOf(AsyncData.Uninitialized)
@@ -108,9 +106,6 @@ class LoginHelper @Inject constructor(
108106
}
109107
is OidcAction.Success -> {
110108
authenticationService.loginWithOidc(oidcAction.url)
111-
.onSuccess { _ ->
112-
defaultLoginUserStory.setLoginFlowIsDone(true)
113-
}
114109
.onFailure { failure ->
115110
loginModeState.value = AsyncData.Failure(failure)
116111
}

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/qrcode/QrCodeLoginFlowNode.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import com.bumble.appyx.navmodel.backstack.operation.replace
2424
import dagger.assisted.Assisted
2525
import dagger.assisted.AssistedInject
2626
import io.element.android.anvilannotations.ContributesNode
27-
import io.element.android.features.login.impl.DefaultLoginUserStory
2827
import io.element.android.features.login.impl.di.QrCodeLoginBindings
2928
import io.element.android.features.login.impl.di.QrCodeLoginComponent
3029
import io.element.android.features.login.impl.screens.qrcode.confirmation.QrCodeConfirmationNode
@@ -54,7 +53,6 @@ class QrCodeLoginFlowNode @AssistedInject constructor(
5453
@Assisted buildContext: BuildContext,
5554
@Assisted plugins: List<Plugin>,
5655
qrCodeLoginComponentBuilder: QrCodeLoginComponent.Builder,
57-
private val defaultLoginUserStory: DefaultLoginUserStory,
5856
private val coroutineDispatchers: CoroutineDispatchers,
5957
) : BaseFlowNode<QrCodeLoginFlowNode.NavTarget>(
6058
backstack = BackStack(
@@ -198,7 +196,6 @@ class QrCodeLoginFlowNode @AssistedInject constructor(
198196
authenticationJob = launch(coroutineDispatchers.main) {
199197
qrCodeLoginManager.authenticate(qrCodeLoginData)
200198
.onSuccess {
201-
defaultLoginUserStory.setLoginFlowIsDone(true)
202199
authenticationJob = null
203200
}
204201
.onFailure { throwable ->

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/createaccount/CreateAccountPresenter.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import androidx.compose.runtime.rememberCoroutineScope
1616
import dagger.assisted.Assisted
1717
import dagger.assisted.AssistedFactory
1818
import dagger.assisted.AssistedInject
19-
import io.element.android.features.login.impl.DefaultLoginUserStory
2019
import io.element.android.libraries.architecture.AsyncAction
2120
import io.element.android.libraries.architecture.Presenter
2221
import io.element.android.libraries.core.data.tryOrNull
@@ -36,7 +35,6 @@ class CreateAccountPresenter @AssistedInject constructor(
3635
@Assisted private val url: String,
3736
private val authenticationService: MatrixAuthenticationService,
3837
private val clientProvider: MatrixClientProvider,
39-
private val defaultLoginUserStory: DefaultLoginUserStory,
4038
private val messageParser: MessageParser,
4139
private val buildMeta: BuildMeta,
4240
) : Presenter<CreateAccountState> {
@@ -86,8 +84,6 @@ class CreateAccountPresenter @AssistedInject constructor(
8684
val sessionVerificationService = client.sessionVerificationService()
8785
withTimeout(10.seconds) { sessionVerificationService.sessionVerifiedStatus.first { it.isVerified() } }
8886
}
89-
// We will not navigate to the WaitList screen, so the login user story is done
90-
defaultLoginUserStory.setLoginFlowIsDone(true)
9187
loggedInState.value = AsyncAction.Success(sessionId)
9288
}.onFailure { failure ->
9389
loggedInState.value = AsyncAction.Failure(failure)

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordPresenter.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import androidx.compose.runtime.mutableStateOf
1515
import androidx.compose.runtime.remember
1616
import androidx.compose.runtime.rememberCoroutineScope
1717
import androidx.compose.runtime.saveable.rememberSaveable
18-
import io.element.android.features.login.impl.DefaultLoginUserStory
1918
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
2019
import io.element.android.libraries.architecture.AsyncData
2120
import io.element.android.libraries.architecture.Presenter
@@ -28,7 +27,6 @@ import javax.inject.Inject
2827
class LoginPasswordPresenter @Inject constructor(
2928
private val authenticationService: MatrixAuthenticationService,
3029
private val accountProviderDataSource: AccountProviderDataSource,
31-
private val defaultLoginUserStory: DefaultLoginUserStory,
3230
) : Presenter<LoginPasswordState> {
3331
@Composable
3432
override fun present(): LoginPasswordState {
@@ -69,8 +67,6 @@ class LoginPasswordPresenter @Inject constructor(
6967
loggedInState.value = AsyncData.Loading()
7068
authenticationService.login(formState.login.trim(), formState.password)
7169
.onSuccess { sessionId ->
72-
// We will not navigate to the WaitList screen, so the login user story is done
73-
defaultLoginUserStory.setLoginFlowIsDone(true)
7470
loggedInState.value = AsyncData.Success(sessionId)
7571
}
7672
.onFailure { failure ->

features/login/impl/src/test/kotlin/io/element/android/features/login/impl/qrcode/QrCodeLoginFlowNodeTest.kt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import com.bumble.appyx.core.modality.AncestryInfo
1212
import com.bumble.appyx.core.modality.BuildContext
1313
import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl
1414
import com.google.common.truth.Truth.assertThat
15-
import io.element.android.features.login.impl.DefaultLoginUserStory
1615
import io.element.android.features.login.impl.di.FakeMergedQrCodeLoginComponent
1716
import io.element.android.features.login.impl.screens.qrcode.confirmation.QrCodeConfirmationStep
1817
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
@@ -98,7 +97,7 @@ class QrCodeLoginFlowNodeTest {
9897

9998
@OptIn(ExperimentalCoroutinesApi::class)
10099
@Test
101-
fun `startAuthentication - success marks the login flow as done`() = runTest {
100+
fun `startAuthentication - success`() = runTest {
102101
val fakeAuthenticationService = FakeMatrixAuthenticationService(
103102
loginWithQrCodeResult = { _, progress ->
104103
progress(QrCodeLoginStep.Finished)
@@ -107,12 +106,8 @@ class QrCodeLoginFlowNodeTest {
107106
)
108107
// Test with a real manager to ensure the flow is correctly done
109108
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
110-
val defaultLoginUserStory = DefaultLoginUserStory().apply {
111-
loginFlowIsDone.value = false
112-
}
113109
val flowNode = createLoginFlowNode(
114110
qrCodeLoginManager = qrCodeLoginManager,
115-
defaultLoginUserStory = defaultLoginUserStory,
116111
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
117112
)
118113

@@ -122,7 +117,6 @@ class QrCodeLoginFlowNodeTest {
122117
advanceUntilIdle()
123118

124119
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Finished)
125-
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isTrue()
126120
assertThat(flowNode.isLoginInProgress()).isFalse()
127121
}
128122

@@ -137,12 +131,8 @@ class QrCodeLoginFlowNodeTest {
137131
)
138132
// Test with a real manager to ensure the flow is correctly done
139133
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
140-
val defaultLoginUserStory = DefaultLoginUserStory().apply {
141-
loginFlowIsDone.value = false
142-
}
143134
val flowNode = createLoginFlowNode(
144135
qrCodeLoginManager = qrCodeLoginManager,
145-
defaultLoginUserStory = defaultLoginUserStory,
146136
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
147137
)
148138

@@ -152,7 +142,6 @@ class QrCodeLoginFlowNodeTest {
152142
advanceUntilIdle()
153143

154144
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Failed(QrLoginException.Unknown))
155-
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
156145
assertThat(flowNode.isLoginInProgress()).isFalse()
157146
}
158147

@@ -167,12 +156,8 @@ class QrCodeLoginFlowNodeTest {
167156
)
168157
// Test with a real manager to ensure the flow is correctly done
169158
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
170-
val defaultLoginUserStory = DefaultLoginUserStory().apply {
171-
loginFlowIsDone.value = false
172-
}
173159
val flowNode = createLoginFlowNode(
174160
qrCodeLoginManager = qrCodeLoginManager,
175-
defaultLoginUserStory = defaultLoginUserStory,
176161
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
177162
)
178163

@@ -183,13 +168,11 @@ class QrCodeLoginFlowNodeTest {
183168
advanceUntilIdle()
184169

185170
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Uninitialized)
186-
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
187171
assertThat(flowNode.isLoginInProgress()).isFalse()
188172
}
189173

190174
private fun TestScope.createLoginFlowNode(
191175
qrCodeLoginManager: QrCodeLoginManager = FakeQrCodeLoginManager(),
192-
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory(),
193176
coroutineDispatchers: CoroutineDispatchers = testCoroutineDispatchers()
194177
): QrCodeLoginFlowNode {
195178
val buildContext = BuildContext(
@@ -201,7 +184,6 @@ class QrCodeLoginFlowNodeTest {
201184
buildContext = buildContext,
202185
plugins = emptyList(),
203186
qrCodeLoginComponentBuilder = FakeMergedQrCodeLoginComponent.Builder(qrCodeLoginManager),
204-
defaultLoginUserStory = defaultLoginUserStory,
205187
coroutineDispatchers = coroutineDispatchers,
206188
)
207189
}

features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenterTest.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import app.cash.turbine.test
1313
import com.google.common.truth.Truth.assertThat
1414
import io.element.android.appconfig.AuthenticationConfig
1515
import io.element.android.features.enterprise.test.FakeEnterpriseService
16-
import io.element.android.features.login.impl.DefaultLoginUserStory
1716
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
1817
import io.element.android.features.login.impl.login.LoginMode
1918
import io.element.android.features.login.impl.screens.createaccount.AccountCreationNotSupported
@@ -30,7 +29,6 @@ import io.element.android.libraries.oidc.api.OidcAction
3029
import io.element.android.libraries.oidc.api.OidcActionFlow
3130
import io.element.android.libraries.oidc.test.customtab.FakeOidcActionFlow
3231
import io.element.android.tests.testutils.WarmUpRule
33-
import io.element.android.tests.testutils.waitForPredicate
3432
import kotlinx.coroutines.test.runTest
3533
import org.junit.Rule
3634
import org.junit.Test
@@ -186,13 +184,9 @@ class ConfirmAccountProviderPresenterTest {
186184
fun `present - oidc - success with success`() = runTest {
187185
val authenticationService = FakeMatrixAuthenticationService()
188186
val defaultOidcActionFlow = FakeOidcActionFlow()
189-
val defaultLoginUserStory = DefaultLoginUserStory().apply {
190-
setLoginFlowIsDone(false)
191-
}
192187
val presenter = createConfirmAccountProviderPresenter(
193188
matrixAuthenticationService = authenticationService,
194189
defaultOidcActionFlow = defaultOidcActionFlow,
195-
defaultLoginUserStory = defaultLoginUserStory,
196190
)
197191
authenticationService.givenHomeserver(A_HOMESERVER_OIDC)
198192
moleculeFlow(RecompositionMode.Immediate) {
@@ -207,11 +201,9 @@ class ConfirmAccountProviderPresenterTest {
207201
assertThat(successState.submitEnabled).isFalse()
208202
assertThat(successState.loginMode).isInstanceOf(AsyncData.Success::class.java)
209203
assertThat(successState.loginMode.dataOrNull()).isInstanceOf(LoginMode.Oidc::class.java)
210-
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
211204
defaultOidcActionFlow.post(OidcAction.Success("aUrl"))
212205
val successSuccessState = awaitItem()
213206
assertThat(successSuccessState.loginMode).isInstanceOf(AsyncData.Loading::class.java)
214-
waitForPredicate { defaultLoginUserStory.loginFlowIsDone.value }
215207
}
216208
}
217209

@@ -357,15 +349,13 @@ class ConfirmAccountProviderPresenterTest {
357349
accountProviderDataSource: AccountProviderDataSource = AccountProviderDataSource(FakeEnterpriseService()),
358350
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
359351
defaultOidcActionFlow: OidcActionFlow = FakeOidcActionFlow(),
360-
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory(),
361352
webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever = FakeWebClientUrlForAuthenticationRetriever(),
362353
) = ConfirmAccountProviderPresenter(
363354
params = params,
364355
accountProviderDataSource = accountProviderDataSource,
365356
loginHelper = createLoginHelper(
366357
authenticationService = matrixAuthenticationService,
367358
oidcActionFlow = defaultOidcActionFlow,
368-
defaultLoginUserStory = defaultLoginUserStory,
369359
webClientUrlForAuthenticationRetriever = webClientUrlForAuthenticationRetriever,
370360
),
371361
)

0 commit comments

Comments
 (0)