feat: simplify color handling in ChatsListScreen and improve gesture callbacks in SwipeableDialogItem

This commit is contained in:
2026-02-12 20:09:53 +05:00
parent ea537ccce1
commit e208ce050a
16 changed files with 419 additions and 365 deletions

View File

@@ -118,6 +118,32 @@ class AccountManager(private val context: Context) {
saveAccount(updatedAccount)
}
/**
* Delete account completely - remove from accounts list and clear login state
*/
suspend fun deleteAccount(publicKey: String) {
context.accountDataStore.edit { preferences ->
// Remove from accounts list
val existingJson = preferences[ACCOUNTS_JSON]
if (existingJson != null) {
val accounts = parseAccounts(existingJson).toMutableList()
accounts.removeAll { it.publicKey == publicKey }
preferences[ACCOUNTS_JSON] = serializeAccounts(accounts)
}
// Clear current login if this was the active account
val currentKey = preferences[CURRENT_PUBLIC_KEY]
if (currentKey == publicKey) {
preferences[IS_LOGGED_IN] = false
preferences.remove(CURRENT_PUBLIC_KEY)
}
}
// Clear SharedPreferences if this was the last logged account
val lastLogged = sharedPrefs.getString(KEY_LAST_LOGGED, null)
if (lastLogged == publicKey) {
sharedPrefs.edit().remove(KEY_LAST_LOGGED).commit()
}
}
suspend fun clearAll() {
context.accountDataStore.edit { it.clear() }
}