Skip to content

Commit 23b18fc

Browse files
committed
advanceLocalLastReadMessageIfNeeded when new messages were received
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
1 parent 3ac4b7f commit 23b18fc

1 file changed

Lines changed: 1 addition & 56 deletions

File tree

app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,13 +1039,6 @@ class ChatActivity :
10391039
lifecycleScope.launchWhenStarted {
10401040
chatViewModel.viewState.collect { state ->
10411041
when (state) {
1042-
// is ChatViewModel.ChatMessageViewState.Initial -> {
1043-
// cancelNotificationsForCurrentConversation()
1044-
// binding.progressBar.visibility = View.GONE
1045-
// binding.offline.root.visibility = View.GONE
1046-
// binding.messagesListView.visibility = View.VISIBLE
1047-
// collapseSystemMessages()
1048-
// }
10491042
is ChatViewModel.ChatMessageViewState.StartRendering -> {
10501043
binding.progressBar.visibility = View.GONE
10511044
binding.offline.root.visibility = View.GONE
@@ -1084,6 +1077,7 @@ class ChatActivity :
10841077
// With Jetpack Compose the flow will be used directly in the UI instead to clear and add everything.
10851078
adapter!!.clear()
10861079
adapter!!.addToEnd(transformedMessages, false)
1080+
advanceLocalLastReadMessageIfNeeded()
10871081
}
10881082
}
10891083
}
@@ -1095,55 +1089,6 @@ class ChatActivity :
10951089
}
10961090
}
10971091

1098-
1099-
// chatViewModel.getMessageFlow
1100-
// .onEach { triple ->
1101-
// val lookIntoFuture = triple.first
1102-
// val setUnreadMessagesMarker = triple.second
1103-
// var chatMessageList = triple.third
1104-
//
1105-
// chatMessageList = handleSystemMessages(chatMessageList)
1106-
// chatMessageList = handleThreadMessages(chatMessageList)
1107-
// if (chatMessageList.isEmpty()) {
1108-
// return@onEach
1109-
// }
1110-
//
1111-
// determinePreviousMessageIds(chatMessageList)
1112-
//
1113-
// handleExpandableSystemMessages(chatMessageList)
1114-
//
1115-
// if (ChatMessage.SystemMessageType.CLEARED_CHAT == chatMessageList[0].systemMessageType) {
1116-
// adapter?.clear()
1117-
// adapter?.notifyDataSetChanged()
1118-
// }
1119-
//
1120-
// if (lookIntoFuture) {
1121-
// Log.d(TAG, "chatMessageList.size in getMessageFlow:" + chatMessageList.size)
1122-
// processMessagesFromTheFuture(chatMessageList, setUnreadMessagesMarker)
1123-
// } else {
1124-
// processMessagesNotFromTheFuture(chatMessageList)
1125-
// collapseSystemMessages()
1126-
// }
1127-
//
1128-
// processExpiredMessages()
1129-
// processCallStartedMessages()
1130-
//
1131-
// adapter?.notifyDataSetChanged()
1132-
// }
1133-
// .debounce(300)
1134-
// .onEach {
1135-
// advanceLocalLastReadMessageIfNeeded()
1136-
// }
1137-
// .launchIn(lifecycleScope)
1138-
1139-
// this.lifecycleScope.launch {
1140-
// chatViewModel.getRemoveMessageFlow
1141-
// .onEach {
1142-
// removeMessageById(it.id)
1143-
// }
1144-
// .collect()
1145-
// }
1146-
11471092
this.lifecycleScope.launch {
11481093
chatViewModel.getUpdateMessageFlow
11491094
.onEach {

0 commit comments

Comments
 (0)