feat: enhance profile fetching and update mechanisms in ProtocolManager and MainScreen

This commit is contained in:
2026-02-06 20:58:28 +05:00
parent dcc719ec56
commit d03f76391c
6 changed files with 150 additions and 27 deletions

View File

@@ -514,6 +514,18 @@ fun MainScreen(
// Состояние протокола для передачи в SearchScreen
val protocolState by ProtocolManager.state.collectAsState()
// Перечитать username/name после получения own profile с сервера
// Аналог Desktop: useUserInformation автоматически обновляет UI при PacketSearch ответе
LaunchedEffect(protocolState) {
if (protocolState == ProtocolState.AUTHENTICATED && accountPublicKey.isNotBlank() && accountPublicKey != "04c266b98ae5") {
delay(2000) // Ждём fetchOwnProfile() → PacketSearch → AccountManager update
val accountManager = AccountManager(context)
val encryptedAccount = accountManager.getAccount(accountPublicKey)
accountUsername = encryptedAccount?.username ?: ""
accountName = encryptedAccount?.name ?: accountName
}
}
// Навигация между экранами
var selectedUser by remember { mutableStateOf<SearchUser?>(null) }