File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
app/src/main/java/com/nextcloud/talk/chat Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -673,7 +673,7 @@ class ChatActivity :
673673
674674 this .lifecycleScope.launch {
675675 chatViewModel.getConversationFlow
676- .onEach { conversationModel ->
676+ .collect { conversationModel ->
677677 currentConversation = conversationModel
678678 chatViewModel.updateConversation(
679679 currentConversation!!
@@ -701,15 +701,17 @@ class ChatActivity :
701701 conversationModel.lastPinnedId.toString()
702702 )
703703 .collect { message ->
704- binding.pinnedMessageContainer.visibility = View .VISIBLE
705- binding.pinnedMessageComposeView.setContent {
706- PinnedMessageView (message)
704+ message?.let {
705+ binding.pinnedMessageContainer.visibility = View .VISIBLE
706+ binding.pinnedMessageComposeView.setContent {
707+ PinnedMessageView (message)
708+ }
707709 }
708710 }
709711 } else {
710712 binding.pinnedMessageContainer.visibility = View .GONE
711713 }
712- }.collect()
714+ }
713715 }
714716
715717 chatViewModel.getRoomViewState.observe(this ) { state ->
Original file line number Diff line number Diff line change @@ -806,7 +806,7 @@ class ChatViewModel @Inject constructor(
806806 baseUrl : String ,
807807 token : String ,
808808 messageId : String
809- ): Flow <ChatMessage > =
809+ ): Flow <ChatMessage ? > =
810810 flow {
811811 val messages = chatNetworkDataSource.getContextForChatMessage(
812812 credentials = credentials,
@@ -817,8 +817,12 @@ class ChatViewModel @Inject constructor(
817817 threadId = null
818818 )
819819
820- val message = messages[0 ]
821- emit(message.asModel())
820+ if (messages.isNotEmpty()) {
821+ val message = messages[0 ]
822+ emit(message.asModel())
823+ } else {
824+ emit(null )
825+ }
822826 }
823827
824828 suspend fun getNumberOfThreadReplies (threadId : Long ): Int = chatRepository.getNumberOfThreadReplies(threadId)
You can’t perform that action at this time.
0 commit comments