kotlin: refactor chat contexts 1 (remove functions creating indirection) (#5827)

* kotlin: refactor chat contexts 1

* remove withChats

* comment

* remove withReportChatsIfOpen

* remove comment

* fix desktop
This commit is contained in:
spaced4ndy authored and GitHub committed 2025-04-14 17:01:22 +01:00
1 parent 14d9240995
commit 38c2529d8b
33 files changed
+598 -580

No files matched your search

@@ -14,8 +14,6 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.*
import chat.simplex.common.model.*
import chat.simplex.common.model.ChatModel.withChats
import chat.simplex.common.model.ChatModel.withReportsChatsIfOpen
import chat.simplex.common.platform.*
import chat.simplex.common.ui.theme.DEFAULT_START_MODAL_WIDTH
import chat.simplex.common.ui.theme.SimpleXTheme
@@ -58,12 +56,14 @@ fun showApp() {
} else {
// The last possible cause that can be closed
withApi {
withChats {
withContext(Dispatchers.Main) {
chatModel.chatId.value = null
chatItems.clearAndNotify()
chatModel.chatsContext.chatItems.clearAndNotify()
}
withReportsChatsIfOpen {
chatItems.clearAndNotify()
withContext(Dispatchers.Main) {
if (ModalManager.end.hasModalOpen(ModalViewId.SECONDARY_CHAT)) {
chatModel.secondaryChatsContext.chatItems.clearAndNotify()
}
}
}
}