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
2025-04-14 16:01:22 +00:00
committed by GitHub
parent 14d9240995
commit 38c2529d8b
33 changed files with 598 additions and 580 deletions
@@ -14,12 +14,11 @@ import androidx.compose.runtime.*
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import chat.simplex.common.AppScreen
import chat.simplex.common.model.ChatModel.withChats
import chat.simplex.common.model.clear
import chat.simplex.common.model.clearAndNotify
import chat.simplex.common.views.helpers.*
import androidx.compose.ui.platform.LocalContext as LocalContext1
import chat.simplex.res.MR
import kotlinx.coroutines.*
actual fun showToast(text: String, timeout: Long) = Toast.makeText(androidAppContext, text, Toast.LENGTH_SHORT).show()
@@ -76,13 +75,13 @@ actual class GlobalExceptionsHandler: Thread.UncaughtExceptionHandler {
ModalManager.start.closeModal()
} else if (chatModel.chatId.value != null) {
withApi {
withChats {
withContext(Dispatchers.Main) {
// Since no modals are open, the problem is probably in ChatView
chatModel.chatId.value = null
chatItems.clearAndNotify()
chatModel.chatsContext.chatItems.clearAndNotify()
}
withChats {
chatItems.clearAndNotify()
withContext(Dispatchers.Main) {
chatModel.chatsContext.chatItems.clearAndNotify()
}
}
} else {