Релиз 1.1.6: сессии, аватарки и интерфейсные исправления

This commit is contained in:
2026-03-10 23:25:03 +05:00
parent 9d0cab3f53
commit 810913b28e
9 changed files with 202 additions and 32 deletions

View File

@@ -72,6 +72,8 @@ class MainActivity : FragmentActivity() {
companion object {
private const val TAG = "MainActivity"
// Process-memory session cache: lets app return without password while process is alive.
private var cachedDecryptedAccount: DecryptedAccount? = null
// 🔔 FCM Логи для отображения в UI
private val _fcmLogs = mutableStateListOf<String>()
@@ -87,8 +89,18 @@ class MainActivity : FragmentActivity() {
}
}
fun clearFcmLogs() {
_fcmLogs.clear()
fun clearFcmLogs() {
_fcmLogs.clear()
}
private fun cacheSessionAccount(account: DecryptedAccount?) {
cachedDecryptedAccount = account
}
private fun getCachedSessionAccount(): DecryptedAccount? = cachedDecryptedAccount
private fun clearCachedSessionAccount() {
cachedDecryptedAccount = null
}
}
@@ -152,14 +164,12 @@ class MainActivity : FragmentActivity() {
var showSplash by remember { mutableStateOf(true) }
var showOnboarding by remember { mutableStateOf(true) }
var hasExistingAccount by remember { mutableStateOf<Boolean?>(null) }
var currentAccount by remember { mutableStateOf<DecryptedAccount?>(null) }
var currentAccount by remember { mutableStateOf(getCachedSessionAccount()) }
var accountInfoList by remember { mutableStateOf<List<AccountInfo>>(emptyList()) }
var startCreateAccountFlow by remember { mutableStateOf(false) }
// Check for existing accounts and build AccountInfo list
// Also force logout so user always sees unlock screen on app restart
LaunchedEffect(Unit) {
accountManager.logout() // Always start logged out
val accounts = accountManager.getAllAccounts()
hasExistingAccount = accounts.isNotEmpty()
accountInfoList = accounts.map { it.toAccountInfo() }
@@ -239,6 +249,7 @@ class MainActivity : FragmentActivity() {
onAuthComplete = { account ->
startCreateAccountFlow = false
currentAccount = account
cacheSessionAccount(account)
hasExistingAccount = true
// Save as last logged account
account?.let {
@@ -256,6 +267,7 @@ class MainActivity : FragmentActivity() {
// Set currentAccount to null immediately to prevent UI
// lag
currentAccount = null
clearCachedSessionAccount()
scope.launch {
com.rosetta.messenger.network.ProtocolManager
.disconnect()
@@ -283,6 +295,7 @@ class MainActivity : FragmentActivity() {
// Set currentAccount to null immediately to prevent UI
// lag
currentAccount = null
clearCachedSessionAccount()
scope.launch {
com.rosetta.messenger.network.ProtocolManager
.disconnect()
@@ -315,6 +328,7 @@ class MainActivity : FragmentActivity() {
hasExistingAccount = accounts.isNotEmpty()
// 8. Navigate away last
currentAccount = null
clearCachedSessionAccount()
} catch (e: Exception) {
android.util.Log.e("DeleteAccount", "Failed to delete account", e)
}
@@ -353,6 +367,7 @@ class MainActivity : FragmentActivity() {
// 9. If current account is deleted, return to main login screen
if (currentAccount?.publicKey == targetPublicKey) {
currentAccount = null
clearCachedSessionAccount()
}
} catch (e: Exception) {
android.util.Log.e("DeleteAccount", "Failed to delete account from sidebar", e)
@@ -367,6 +382,7 @@ class MainActivity : FragmentActivity() {
// Switch to another account: logout current, then show unlock.
currentAccount = null
clearCachedSessionAccount()
scope.launch {
com.rosetta.messenger.network.ProtocolManager.disconnect()
accountManager.logout()
@@ -375,6 +391,7 @@ class MainActivity : FragmentActivity() {
onAddAccount = {
startCreateAccountFlow = true
currentAccount = null
clearCachedSessionAccount()
scope.launch {
com.rosetta.messenger.network.ProtocolManager.disconnect()
accountManager.logout()
@@ -387,6 +404,7 @@ class MainActivity : FragmentActivity() {
isDarkTheme = isDarkTheme,
onExit = {
currentAccount = null
clearCachedSessionAccount()
scope.launch {
ProtocolManager.disconnect()
accountManager.logout()