feat: Integrate AccountManager to retrieve last logged account in AuthFlow and update MainActivity

This commit is contained in:
2026-01-16 06:18:47 +05:00
parent c52e6dda53
commit b1046f88e5
12 changed files with 24 additions and 242 deletions

View File

@@ -5,6 +5,7 @@ import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.runtime.*
import com.rosetta.messenger.data.DecryptedAccount
import com.rosetta.messenger.data.AccountManager
enum class AuthScreen {
SELECT_ACCOUNT,
@@ -21,6 +22,7 @@ fun AuthFlow(
isDarkTheme: Boolean,
hasExistingAccount: Boolean,
accounts: List<AccountInfo> = emptyList(),
accountManager: AccountManager,
onAuthComplete: (DecryptedAccount?) -> Unit,
onLogout: () -> Unit = {}
) {
@@ -33,7 +35,12 @@ fun AuthFlow(
)
}
var seedPhrase by remember { mutableStateOf<List<String>>(emptyList()) }
var selectedAccountId by remember { mutableStateOf<String?>(accounts.firstOrNull()?.id) }
// Use last logged account or fallback to first account
var selectedAccountId by remember {
mutableStateOf<String?>(
accountManager.getLastLoggedPublicKey() ?: accounts.firstOrNull()?.id
)
}
var showCreateModal by remember { mutableStateOf(false) }
// Handle system back button