feat: Update profile saving logic to follow desktop version pattern and enhance local data handling

This commit is contained in:
k1ngsterr1
2026-01-22 00:05:37 +05:00
parent 7d85d2c6e9
commit 1764fded5e
7 changed files with 694 additions and 30 deletions

View File

@@ -439,10 +439,11 @@ fun MainScreen(
val privateKeyHash = account?.privateKeyHash ?: ""
// Username state - загружается из EncryptedAccount
// Following desktop version pattern: username is stored locally and loaded on app start
var accountUsername by remember { mutableStateOf("") }
var reloadTrigger by remember { mutableIntStateOf(0) }
// Load username from AccountManager
// Load username from AccountManager (persisted in DataStore)
val context = LocalContext.current
LaunchedEffect(accountPublicKey, reloadTrigger) {
if (accountPublicKey.isNotBlank() && accountPublicKey != "04c266b98ae5") {
@@ -706,7 +707,10 @@ fun MainScreen(
accountPrivateKeyHash = privateKeyHash,
onBack = { showProfileScreen = false },
onSaveProfile = { name, username ->
// Update username state and trigger reload from DB
// Following desktop version pattern:
// 1. Server confirms save (handled in ProfileViewModel)
// 2. Local DB updated (handled in ProfileScreen LaunchedEffect)
// 3. This callback updates UI state (reloads username from DB)
accountUsername = username
reloadTrigger++
Log.d("MainActivity", "Profile saved: name=$name, username=$username, reloading...")