@@ -48,6 +48,8 @@ import io.element.android.libraries.architecture.waitForChildAttached
48
48
import io.element.android.libraries.core.uri.ensureProtocol
49
49
import io.element.android.libraries.deeplink.api.DeeplinkData
50
50
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
51
+ import io.element.android.libraries.featureflag.api.FeatureFlagService
52
+ import io.element.android.libraries.featureflag.api.FeatureFlags
51
53
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
52
54
import io.element.android.libraries.matrix.api.core.SessionId
53
55
import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
@@ -81,6 +83,7 @@ class RootFlowNode(
81
83
private val oidcActionFlow : OidcActionFlow ,
82
84
private val bugReporter : BugReporter ,
83
85
private val sessionStore : SessionStore ,
86
+ private val featureFlagService : FeatureFlagService ,
84
87
) : BaseFlowNode<RootFlowNode.NavTarget>(
85
88
backstack = BackStack (
86
89
initialElement = NavTarget .SplashScreen ,
@@ -335,15 +338,19 @@ class RootFlowNode(
335
338
// Is there a session already?
336
339
val sessions = sessionStore.getAllSessions()
337
340
if (sessions.isNotEmpty()) {
338
- val loginHintMatrixId = params.loginHint?.removePrefix(" mxid:" )
339
- val existingAccount = sessions.find { it.userId == loginHintMatrixId }
340
- if (existingAccount != null ) {
341
- // We have an existing account matching the login hint, ensure this is the current session
342
- sessionStore.setLatestSession(existingAccount.userId)
341
+ if (featureFlagService.isFeatureEnabled(FeatureFlags .MultiAccount )) {
342
+ val loginHintMatrixId = params.loginHint?.removePrefix(" mxid:" )
343
+ val existingAccount = sessions.find { it.userId == loginHintMatrixId }
344
+ if (existingAccount != null ) {
345
+ // We have an existing account matching the login hint, ensure this is the current session
346
+ sessionStore.setLatestSession(existingAccount.userId)
347
+ } else {
348
+ val latestSessionId = sessions.maxBy { it.lastUsageIndex }.userId
349
+ attachSession(SessionId (latestSessionId))
350
+ backstack.push(NavTarget .NotLoggedInFlow (params))
351
+ }
343
352
} else {
344
- val latestSessionId = sessions.maxBy { it.lastUsageIndex }.userId
345
- attachSession(SessionId (latestSessionId))
346
- backstack.push(NavTarget .NotLoggedInFlow (params))
353
+ Timber .w(" Login link ignored, multi account is disabled" )
347
354
}
348
355
} else {
349
356
switchToNotLoggedInFlow(params)
0 commit comments