feat: Safely set last logged account public key using null safety
This commit is contained in:
@@ -176,6 +176,8 @@ fun ChatDetailScreen(
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
val focusManager = LocalFocusManager.current
|
||||
val clipboardManager = androidx.compose.ui.platform.LocalClipboardManager.current
|
||||
val context = LocalContext.current
|
||||
val database = remember { com.rosetta.messenger.database.RosettaDatabase.getDatabase(context) }
|
||||
// Цвета как в React Native themes.ts
|
||||
val backgroundColor = if (isDarkTheme) Color(0xFF1E1E1E) else Color(0xFFFFFFFF)
|
||||
val textColor = if (isDarkTheme) Color.White else Color.Black
|
||||
@@ -1103,7 +1105,22 @@ fun ChatDetailScreen(
|
||||
TextButton(
|
||||
onClick = {
|
||||
showDeleteConfirm = false
|
||||
// TODO: Implement delete chat
|
||||
scope.launch {
|
||||
try {
|
||||
// Delete all messages in this dialog
|
||||
database.messageDao().deleteDialog(
|
||||
account = currentUserPublicKey,
|
||||
dialogKey = user.publicKey
|
||||
)
|
||||
// Delete dialog cache
|
||||
database.dialogDao().deleteDialog(
|
||||
account = currentUserPublicKey,
|
||||
opponentKey = user.publicKey
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
android.util.Log.e("ChatDetail", "Error deleting chat", e)
|
||||
}
|
||||
}
|
||||
onBack()
|
||||
}
|
||||
) {
|
||||
@@ -1140,7 +1157,21 @@ fun ChatDetailScreen(
|
||||
TextButton(
|
||||
onClick = {
|
||||
showBlockConfirm = false
|
||||
// TODO: Implement block user
|
||||
scope.launch {
|
||||
try {
|
||||
// Add user to blacklist
|
||||
database.blacklistDao().blockUser(
|
||||
com.rosetta.messenger.database.BlacklistEntity(
|
||||
publicKey = user.publicKey,
|
||||
account = currentUserPublicKey
|
||||
)
|
||||
)
|
||||
android.util.Log.d("ChatDetail", "User blocked: ${user.publicKey.take(10)}")
|
||||
} catch (e: Exception) {
|
||||
android.util.Log.e("ChatDetail", "Error blocking user", e)
|
||||
}
|
||||
}
|
||||
onBack()
|
||||
}
|
||||
) {
|
||||
Text("Block", color = Color(0xFFFF3B30))
|
||||
@@ -1193,8 +1224,8 @@ private fun MessageBubble(
|
||||
onLongClick: () -> Unit = {},
|
||||
onClick: () -> Unit = {}
|
||||
) {
|
||||
// Telegram-style enter animation
|
||||
val (alpha, translationY) = rememberMessageEnterAnimation(message.id)
|
||||
// ❌ УБРАЛИ: Telegram-style enter animation - она мешает при скролле
|
||||
// val (alpha, translationY) = rememberMessageEnterAnimation(message.id)
|
||||
|
||||
// Selection animation
|
||||
val selectionScale by animateFloatAsState(
|
||||
@@ -1242,8 +1273,9 @@ private fun MessageBubble(
|
||||
Modifier.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp, vertical = 1.dp)
|
||||
.graphicsLayer {
|
||||
this.alpha = alpha * selectionAlpha
|
||||
this.translationY = translationY
|
||||
// ❌ УБРАЛИ: alpha = alpha * selectionAlpha и translationY
|
||||
// Оставляем только selection анимацию
|
||||
this.alpha = selectionAlpha
|
||||
this.scaleX = selectionScale
|
||||
this.scaleY = selectionScale
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user