Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New state] Set the initial state for read, typing and online indicators #476

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ class ChatChannelDataSource: ChannelDataSource {
private var cancellables = Set<AnyCancellable>()

let chat: Chat
weak var delegate: MessagesDataSource?
@MainActor weak var delegate: MessagesDataSource? {
didSet {
cancellables.removeAll()
guard delegate != nil else { return }
subscribeForMessageUpdates()
subscribeForChannelUpdates()
}
}

@MainActor var messages: StreamCollection<ChatMessage> {
chat.state.messages
Expand All @@ -96,8 +103,6 @@ class ChatChannelDataSource: ChannelDataSource {

@MainActor init(chat: Chat) {
self.chat = chat
subscribeForMessageUpdates()
subscribeForChannelUpdates()
}

@MainActor private func subscribeForMessageUpdates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ import SwiftUI
}

channelName = channel?.name ?? ""
if let channel {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triggered when channel changes, so no need to call it twice

checkHeaderType(for: channel)
}
checkUnreadCount()
}

Expand Down
Loading