From aa76636f7248859f225f674438586b11ef95a671 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 7 Aug 2024 12:43:07 +0200 Subject: [PATCH] handle reaction message for lookIntoFuture Signed-off-by: Marcel Hibbe --- .../com/nextcloud/talk/chat/ChatActivity.kt | 10 ++++------ .../talk/chat/data/ChatMessageRepository.kt | 8 +------- .../network/OfflineFirstChatRepository.kt | 19 +++---------------- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index efc04b6b2..e697fb218 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -827,14 +827,12 @@ class ChatActivity : adapter?.notifyDataSetChanged() } .collect() + } - + this.lifecycleScope.launch { chatViewModel.getUpdateMessageFlow - .onEach { pair -> - val lookIntoFuture = pair.first - var chatMessageList = pair.second - - adapter!!.update(chatMessageList[0]) + .onEach { + updateAdapterForReaction(it) } .collect() } diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt index 529af495a..1b1696b16 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt @@ -30,13 +30,7 @@ interface ChatMessageRepository : LifecycleAwareManager { > > - val updateMessageFlow: - Flow< - Pair< - Boolean, - List - > - > + val updateMessageFlow: Flow fun setData( conversationModel: ConversationModel, diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt index 62fa68758..6cc87dc19 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt @@ -66,21 +66,11 @@ class OfflineFirstChatRepository @Inject constructor( > = MutableSharedFlow() override val updateMessageFlow: - Flow< - Pair< - Boolean, - List - > - > + Flow get() = _updateMessageFlow private val _updateMessageFlow: - MutableSharedFlow< - Pair< - Boolean, - List - > - > = MutableSharedFlow() + MutableSharedFlow = MutableSharedFlow() private var newXChatLastCommonRead: Int? = null private var itIsPaused = false @@ -480,10 +470,7 @@ class OfflineFirstChatRepository @Inject constructor( messageJson.parentMessage?.let { parentMessageJson -> val parentMessageEntity = parentMessageJson.asEntity(currentUser.id!!) chatDao.upsertChatMessage(parentMessageEntity) - // TODO: inform UI to update this message!! - - val pair = Pair(true, listOf(parentMessageEntity.asModel())) - _updateMessageFlow.emit(pair) + _updateMessageFlow.emit(parentMessageEntity.asModel()) } }