diff --git a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt index 93f18e0609..21f5722e0c 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt @@ -34,7 +34,7 @@ import kotlin.concurrent.thread typealias ChatCtrl = Long -open class ChatController(private val ctrl: ChatCtrl, private val ntfManager: NtfManager, val appContext: Context) { +open class ChatController(private val ctrl: ChatCtrl, val ntfManager: NtfManager, val appContext: Context) { var chatModel = ChatModel(this) private val sharedPreferences: SharedPreferences = appContext.getSharedPreferences(SHARED_PREFS_ID, Context.MODE_PRIVATE) @@ -85,10 +85,6 @@ open class ChatController(private val ctrl: ChatCtrl, private val ntfManager: Nt return false } - fun cancelNotificationsForChat(chatId: String) { - ntfManager.cancelNotificationsForChat(chatId) - } - suspend fun sendCmd(cmd: CC): CR { return withContext(Dispatchers.IO) { val c = cmd.cmdString diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt index 7e083d4d5c..50ac856210 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt @@ -35,7 +35,7 @@ fun ChatInfoView(chatModel: ChatModel, close: () -> Unit) { } } -fun deleteContactDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: () -> Unit) { +fun deleteContactDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: (() -> Unit)? = null) { AlertManager.shared.showAlertMsg( title = generalGetString(R.string.delete_contact__question), text = generalGetString(R.string.delete_contact_all_messages_deleted_cannot_undo_warning), @@ -46,14 +46,15 @@ fun deleteContactDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: () -> U if (r) { chatModel.removeChat(chatInfo.id) chatModel.chatId.value = null - close() + chatModel.controller.ntfManager.cancelNotificationsForChat(chatInfo.id) + close?.invoke() } } } ) } -fun clearChatDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: () -> Unit) { +fun clearChatDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: (() -> Unit)? = null) { AlertManager.shared.showAlertMsg( title = generalGetString(R.string.clear_chat_question), text = generalGetString(R.string.clear_chat_warning), @@ -63,7 +64,8 @@ fun clearChatDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: () -> Unit) val updatedChatInfo = chatModel.controller.apiClearChat(chatInfo.chatType, chatInfo.apiId) if (updatedChatInfo != null) { chatModel.clearChat(updatedChatInfo) - close() + chatModel.controller.ntfManager.cancelNotificationsForChat(chatInfo.id) + close?.invoke() } } } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt index 8642d79f37..5f353069c1 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt @@ -59,7 +59,7 @@ fun ChatView(chatModel: ChatModel) { delay(750L) if (chat.chatItems.isNotEmpty()) { chatModel.markChatItemsRead(chat.chatInfo) - chatModel.controller.cancelNotificationsForChat(chat.id) + chatModel.controller.ntfManager.cancelNotificationsForChat(chat.id) withApi { chatModel.controller.apiChatRead( chat.chatInfo.chatType, diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt index 47ab21d004..35faab717f 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt @@ -16,6 +16,8 @@ import androidx.compose.ui.unit.dp import chat.simplex.app.R import chat.simplex.app.model.* import chat.simplex.app.ui.theme.SimpleXTheme +import chat.simplex.app.views.chat.clearChatDialog +import chat.simplex.app.views.chat.deleteContactDialog import chat.simplex.app.views.chat.item.ItemAction import chat.simplex.app.views.helpers.* import kotlinx.coroutines.delay @@ -90,6 +92,7 @@ fun ContactMenuItems(chat: Chat, chatModel: ChatModel, showMenu: MutableStateОтклонить - Очистить разговор? + Очистить чат? Все сообщения будут удалены - это действие нельзя отменить! Сообщения будут удалены только для вас. Очистить - Очистить разговор + Очистить чат Прочитано diff --git a/apps/android/app/src/main/res/values/strings.xml b/apps/android/app/src/main/res/values/strings.xml index 868e7f72b5..3996718c6a 100644 --- a/apps/android/app/src/main/res/values/strings.xml +++ b/apps/android/app/src/main/res/values/strings.xml @@ -170,10 +170,10 @@ Reject - Clear conversation? + Clear chat? All messages will be deleted - this cannot be undone! The messages will be deleted ONLY for you. Clear - Clear conversation + Clear chat Mark read