From 911dd0c2ef8d341397e4dc0b1f8690cdb64cffaf Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Thu, 15 Dec 2022 14:01:03 +0300 Subject: [PATCH] Concurrency test --- .../java/chat/simplex/app/views/chat/ChatView.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 bb606a23a5..04502e3d23 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 @@ -87,6 +87,22 @@ fun ChatView(chatId: String, chatModel: ChatModel, onComposed: () -> Unit) { .filter { it?.chatInfo != activeChat.value?.chatInfo && it != null } .collect { activeChat.value = it } } + launch { + launch(Dispatchers.IO) { + while (true) { + chatModel.chats.add(Chat.sampleData.copy(chatInfo = activeChat.value!!.chatInfo)) + delay(1) + chatModel.chats.remove(Chat.sampleData.copy(chatInfo = activeChat.value!!.chatInfo)) + } + } + launch(Dispatchers.IO) { + while (true) { + chatModel.chats.add(Chat.sampleData.copy(chatInfo = activeChat.value!!.chatInfo)) + delay(1) + chatModel.chats.remove(Chat.sampleData.copy(chatInfo = activeChat.value!!.chatInfo)) + } + } + } } val view = LocalView.current if (activeChat.value == null || user == null) {