Skip to content

Commit fd7f55e

Browse files
Performance improvements for date indicator string
1 parent 9296308 commit fd7f55e

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
5555
}
5656
}
5757
)
58+
.overlay(
59+
viewModel.currentDateString != nil ?
60+
factory.makeDateIndicatorView(dateString: viewModel.currentDateString!)
61+
: nil
62+
)
5863

5964
Divider()
6065
.navigationBarBackButtonHidden(viewModel.reactionsShown)

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelViewModel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
134134
public func handleMessageAppear(index: Int) {
135135
let message = messages[index]
136136
checkForNewMessages(index: index)
137-
// if utils.messageListConfig.dateIndicatorPlacement == .overlay {
138-
// save(lastDate: message.createdAt)
139-
// }
137+
if utils.messageListConfig.dateIndicatorPlacement == .overlay {
138+
save(lastDate: message.createdAt)
139+
}
140140
if index == 0 {
141141
maybeSendReadEvent(for: message)
142142
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListView.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ public struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
176176
onScrollToBottom: onScrollToBottom
177177
)
178178
}
179-
180-
if let date = currentDateString {
181-
factory.makeDateIndicatorView(dateString: date)
182-
}
183179

184180
if shouldShowTypingIndicator {
185181
TypingIndicatorBottomView(

0 commit comments

Comments
 (0)