feat: Update ProfileNavigationItem to use a rounded corner shape with increased radius

This commit is contained in:
k1ngsterr1
2026-01-21 03:09:39 +05:00
parent 5145388e02
commit dcfbb020be
7 changed files with 105 additions and 42 deletions

View File

@@ -412,7 +412,7 @@ fun ProfileScreen(
name = editedName,
username = editedUsername
)
viewModel.updateLocalAccountName(accountPublicKey, editedName)
viewModel.updateLocalProfile(accountPublicKey, editedName, editedUsername)
},
isDarkTheme = isDarkTheme
)
@@ -903,7 +903,7 @@ fun ProfileNavigationItem(
Box(
modifier = Modifier
.size(36.dp)
.clip(RoundedCornerShape(8.dp))
.clip(RoundedCornerShape(16.dp))
.background(iconBackground),
contentAlignment = Alignment.Center
) {

View File

@@ -13,6 +13,7 @@ import com.rosetta.messenger.network.ProtocolManager
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.delay
data class ProfileState(
val isLoading: Boolean = false,
@@ -72,18 +73,47 @@ class ProfileViewModel(application: Application) : AndroidViewModel(application)
_state.value = _state.value.copy(isSaving = true, error = null, saveSuccess = false)
// Create and send PacketUserInfo
// Create and send PacketUserInfo (protocol order: username, title, privateKey)
val packet = PacketUserInfo()
packet.publicKey = publicKey
packet.title = name
packet.username = username
packet.title = name
packet.privateKey = privateKeyHash
addLog("Packet created: PacketUserInfo")
addLog("Packet ID: 0x${packet.getPacketId().toString(16).uppercase()}")
addLog("Packet data:")
addLog(" - username: '$username'")
addLog(" - title: '$name'")
addLog(" - privateKey: ${privateKeyHash.take(16)}...")
addLog("Sending packet to server...")
ProtocolManager.send(packet)
addLog("Packet sent successfully")
addLog("Waiting for PacketResult (0x02) from server...")
// 🔥 ВРЕМЕННОЕ РЕШЕНИЕ: Сохраняем локально сразу (как в React Native)
// Это нужно потому что сервер может не ответить, если пользователь не создан в БД
addLog("💾 Saving to local database (temporary workaround)...")
updateLocalProfile(publicKey, name, username)
addLog("✅ Local database updated")
// Set timeout for server response
viewModelScope.launch {
delay(5000) // 5 seconds timeout
if (_state.value.isSaving) {
addLog("⚠️ WARNING: No response from server after 5 seconds")
addLog("This might indicate:")
addLog(" 1. Server did not accept the packet")
addLog(" 2. Server did not send PacketResult back")
addLog(" 3. Network issue")
addLog("📝 NOTE: Profile saved locally, but NOT confirmed by server")
_state.value = _state.value.copy(
isSaving = false,
saveSuccess = true, // Считаем успехом т.к. локально сохранено
error = null
)
}
}
// Wait for response (handled in handlePacketResult)
@@ -115,10 +145,6 @@ class ProfileViewModel(application: Application) : AndroidViewModel(application)
error = null
)
addLog("State updated: saveSuccess=true")
// Update local account name if needed
// (username is stored on server only)
}
else -> { // ERROR
addLog("❌ ERROR: Profile save failed")
@@ -135,24 +161,16 @@ class ProfileViewModel(application: Application) : AndroidViewModel(application)
}
/**
* Update local account name
* Update local account name and username
*/
fun updateLocalAccountName(publicKey: String, name: String) {
fun updateLocalProfile(publicKey: String, name: String, username: String) {
viewModelScope.launch {
try {
val account = accountManager.getAccount(publicKey)
if (account != null) {
val updatedAccount = EncryptedAccount(
publicKey = account.publicKey,
encryptedPrivateKey = account.encryptedPrivateKey,
encryptedSeedPhrase = account.encryptedSeedPhrase,
name = name
)
accountManager.saveAccount(updatedAccount)
Log.d("ProfileViewModel", "Local account name updated")
}
accountManager.updateAccountName(publicKey, name)
accountManager.updateAccountUsername(publicKey, username)
Log.d("ProfileViewModel", "Local profile updated: name=$name, username=$username")
} catch (e: Exception) {
Log.e("ProfileViewModel", "Error updating local account name", e)
Log.e("ProfileViewModel", "Error updating local profile", e)
}
}
}