diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListScreen.kt index 4ebad1d..0cb147a 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListScreen.kt @@ -571,7 +571,9 @@ fun ChatsListScreen( Text( text = "Delete conversation?", fontWeight = FontWeight.SemiBold, - fontSize = 18.sp + fontSize = 18.sp, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() ) }, text = { @@ -579,7 +581,9 @@ fun ChatsListScreen( Text( text = "All messages with $displayName will be permanently deleted. This action cannot be undone.", fontSize = 15.sp, - color = if (isDarkTheme) Color(0xFFAAAAAA) else Color(0xFF666666) + color = if (isDarkTheme) Color(0xFFAAAAAA) else Color(0xFF666666), + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() ) }, confirmButton = { @@ -625,7 +629,9 @@ fun ChatsListScreen( Text( text = "Block user?", fontWeight = FontWeight.SemiBold, - fontSize = 18.sp + fontSize = 18.sp, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() ) }, text = { @@ -633,7 +639,9 @@ fun ChatsListScreen( Text( text = "$displayName will no longer be able to send you messages. You can unblock them later.", fontSize = 15.sp, - color = if (isDarkTheme) Color(0xFFAAAAAA) else Color(0xFF666666) + color = if (isDarkTheme) Color(0xFFAAAAAA) else Color(0xFF666666), + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() ) }, confirmButton = { @@ -679,7 +687,9 @@ fun ChatsListScreen( Text( text = "Unblock user?", fontWeight = FontWeight.SemiBold, - fontSize = 18.sp + fontSize = 18.sp, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() ) }, text = { @@ -687,7 +697,9 @@ fun ChatsListScreen( Text( text = "$displayName will be able to send you messages again.", fontSize = 15.sp, - color = if (isDarkTheme) Color(0xFFAAAAAA) else Color(0xFF666666) + color = if (isDarkTheme) Color(0xFFAAAAAA) else Color(0xFF666666), + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() ) }, confirmButton = { diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListViewModel.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListViewModel.kt index 845a228..400c6aa 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListViewModel.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatsListViewModel.kt @@ -176,10 +176,24 @@ class ChatsListViewModel(application: Application) : AndroidViewModel(applicatio if (currentAccount.isEmpty()) return try { - // Удаляем все сообщения - database.messageDao().deleteDialog(currentAccount, opponentKey) - // Удаляем диалог - database.dialogDao().deleteDialog(currentAccount, opponentKey) + // Удаляем все сообщения из диалога по dialog_key + database.messageDao().deleteDialog( + account = currentAccount, + dialogKey = opponentKey + ) + // Также удаляем по from/to ключам (на всякий случай) + database.messageDao().deleteMessagesBetweenUsers( + account = currentAccount, + user1 = opponentKey, + user2 = currentAccount + ) + // Очищаем кеш диалога + database.dialogDao().deleteDialog( + account = currentAccount, + opponentKey = opponentKey + ) + + android.util.Log.d("ChatsListViewModel", "Dialog deleted successfully: $opponentKey") } catch (e: Exception) { android.util.Log.e("ChatsListViewModel", "Error deleting dialog", e) }