Skip to content

Commit 9d92c99

Browse files
Fixed a bug with highlighting new messages
1 parent 2e59f44 commit 9d92c99

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
109109
.flippedUpsideDown()
110110
.frame(minWidth: self.width, minHeight: height)
111111
.onChange(of: scrolledId) { scrolledId in
112+
if !self.scrolledIdAvailableInMessages {
113+
self.scrolledId = nil
114+
return
115+
}
112116
if let scrolledId = scrolledId {
113117
if scrolledId == messages.first?.messageId {
114118
self.scrolledId = nil
@@ -157,6 +161,10 @@ struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
157161
.modifier(HideKeyboardOnTapGesture(shouldAdd: keyboardShown))
158162
}
159163

164+
private var scrolledIdAvailableInMessages: Bool {
165+
messages.map(\.messageId).contains(scrolledId)
166+
}
167+
160168
private func showsAllData(for message: ChatMessage) -> Bool {
161169
if !messageListConfig.groupMessages {
162170
return true

0 commit comments

Comments
 (0)