feat: Enhance account handling and message delivery status updates; improve UI feedback for saved messages
This commit is contained in:
@@ -170,6 +170,8 @@ class MainActivity : ComponentActivity() {
|
||||
targetState = when {
|
||||
showSplash -> "splash"
|
||||
showOnboarding && hasExistingAccount == false -> "onboarding"
|
||||
// 🔥 КРИТИЧНО: если currentAccount != null - сразу на main без ожидания isLoggedIn
|
||||
currentAccount != null -> "main"
|
||||
isLoggedIn != true && hasExistingAccount == false -> "auth_new"
|
||||
isLoggedIn != true && hasExistingAccount == true -> "auth_unlock"
|
||||
else -> "main"
|
||||
@@ -210,7 +212,13 @@ class MainActivity : ComponentActivity() {
|
||||
currentAccount = account
|
||||
hasExistingAccount = true
|
||||
// Save as last logged account
|
||||
account?.let { accountManager.setLastLoggedPublicKey(it.publicKey) }
|
||||
account?.let {
|
||||
accountManager.setLastLoggedPublicKey(it.publicKey)
|
||||
// 🔥 КРИТИЧНО: Сразу устанавливаем флаг логина чтобы не было Loading экрана
|
||||
scope.launch {
|
||||
accountManager.setCurrentAccount(it.publicKey)
|
||||
}
|
||||
}
|
||||
|
||||
// 📤 Отправляем FCM токен на сервер после успешной аутентификации
|
||||
account?.let { sendFcmTokenToServer(it) }
|
||||
@@ -354,33 +362,22 @@ fun MainScreen(
|
||||
onToggleTheme: () -> Unit = {},
|
||||
onLogout: () -> Unit = {}
|
||||
) {
|
||||
// 🔥 КРИТИЧНО: Если account == null, показываем загрузку вместо мокового аккаунта
|
||||
if (account == null) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(if (isDarkTheme) Color(0xFF1B1B1B) else Color.White),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
CircularProgressIndicator()
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
"Loading account...",
|
||||
color = if (isDarkTheme) Color.White else Color.Black
|
||||
)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
// 🔥 Используем моковый аккаунт если account == null (для предотвращения крашей)
|
||||
val effectiveAccount = account ?: DecryptedAccount(
|
||||
publicKey = "loading",
|
||||
privateKey = "loading",
|
||||
seedPhrase = emptyList(),
|
||||
privateKeyHash = "loading",
|
||||
name = "Loading..."
|
||||
)
|
||||
|
||||
val accountName = account.name
|
||||
val accountPhone = account.publicKey.take(16).let {
|
||||
val accountName = effectiveAccount.name
|
||||
val accountPhone = effectiveAccount.publicKey.take(16).let {
|
||||
"+${it.take(1)} ${it.substring(1, 4)} ${it.substring(4, 7)}${it.substring(7)}"
|
||||
}
|
||||
val accountPublicKey = account.publicKey
|
||||
val accountPrivateKey = account.privateKey
|
||||
val privateKeyHash = account.privateKeyHash
|
||||
val accountPublicKey = effectiveAccount.publicKey
|
||||
val accountPrivateKey = effectiveAccount.privateKey
|
||||
val privateKeyHash = effectiveAccount.privateKeyHash
|
||||
|
||||
// Состояние протокола для передачи в SearchScreen
|
||||
val protocolState by ProtocolManager.state.collectAsState()
|
||||
|
||||
Reference in New Issue
Block a user