@@ -1017,13 +1017,6 @@ class ChatActivity :
10171017 lifecycleScope.launchWhenStarted {
10181018 chatViewModel.viewState.collect { state ->
10191019 when (state) {
1020- // is ChatViewModel.ChatMessageViewState.Initial -> {
1021- // cancelNotificationsForCurrentConversation()
1022- // binding.progressBar.visibility = View.GONE
1023- // binding.offline.root.visibility = View.GONE
1024- // binding.messagesListView.visibility = View.VISIBLE
1025- // collapseSystemMessages()
1026- // }
10271020 is ChatViewModel .ChatMessageViewState .StartRendering -> {
10281021 binding.progressBar.visibility = View .GONE
10291022 binding.offline.root.visibility = View .GONE
@@ -1062,6 +1055,7 @@ class ChatActivity :
10621055 // With Jetpack Compose the flow will be used directly in the UI instead to clear and add everything.
10631056 adapter!! .clear()
10641057 adapter!! .addToEnd(transformedMessages, false )
1058+ advanceLocalLastReadMessageIfNeeded()
10651059 }
10661060 }
10671061 }
@@ -1073,55 +1067,6 @@ class ChatActivity :
10731067 }
10741068 }
10751069
1076-
1077- // chatViewModel.getMessageFlow
1078- // .onEach { triple ->
1079- // val lookIntoFuture = triple.first
1080- // val setUnreadMessagesMarker = triple.second
1081- // var chatMessageList = triple.third
1082- //
1083- // chatMessageList = handleSystemMessages(chatMessageList)
1084- // chatMessageList = handleThreadMessages(chatMessageList)
1085- // if (chatMessageList.isEmpty()) {
1086- // return@onEach
1087- // }
1088- //
1089- // determinePreviousMessageIds(chatMessageList)
1090- //
1091- // handleExpandableSystemMessages(chatMessageList)
1092- //
1093- // if (ChatMessage.SystemMessageType.CLEARED_CHAT == chatMessageList[0].systemMessageType) {
1094- // adapter?.clear()
1095- // adapter?.notifyDataSetChanged()
1096- // }
1097- //
1098- // if (lookIntoFuture) {
1099- // Log.d(TAG, "chatMessageList.size in getMessageFlow:" + chatMessageList.size)
1100- // processMessagesFromTheFuture(chatMessageList, setUnreadMessagesMarker)
1101- // } else {
1102- // processMessagesNotFromTheFuture(chatMessageList)
1103- // collapseSystemMessages()
1104- // }
1105- //
1106- // processExpiredMessages()
1107- // processCallStartedMessages()
1108- //
1109- // adapter?.notifyDataSetChanged()
1110- // }
1111- // .debounce(300)
1112- // .onEach {
1113- // advanceLocalLastReadMessageIfNeeded()
1114- // }
1115- // .launchIn(lifecycleScope)
1116-
1117- // this.lifecycleScope.launch {
1118- // chatViewModel.getRemoveMessageFlow
1119- // .onEach {
1120- // removeMessageById(it.id)
1121- // }
1122- // .collect()
1123- // }
1124-
11251070 this .lifecycleScope.launch {
11261071 chatViewModel.getUpdateMessageFlow
11271072 .onEach {
0 commit comments