Skip to content

Typing users did not update reliably in the message list #591

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 30, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### 🔄 Changed

### 🐞 Fixed
- Typing users did not update reliably in the message list [#591](https://github.com/GetStream/stream-chat-swiftui/pull/591)

# [4.62.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.62.0)
_August 16, 2024_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
}
}

public var channel: ChatChannel? {
channelController.channel
}
@Published public private(set) var channel: ChatChannel?

public var isMessageThread: Bool {
messageController != nil
Expand Down Expand Up @@ -150,6 +148,7 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
}
channelDataSource.delegate = self
messages = channelDataSource.messages
channel = channelController.channel

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
if let scrollToMessage, let parentMessageId = scrollToMessage.parentMessageId, messageController == nil {
Expand Down Expand Up @@ -445,6 +444,7 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
didUpdateChannel channel: EntityChange<ChatChannel>,
channelController: ChatChannelController
) {
self.channel = channel.item
checkReadIndicators(for: channel)
checkTypingIndicator()
checkHeaderType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,27 @@ import SwiftUI
import XCTest

class ChatChannelViewModel_Tests: StreamChatTestCase {

func test_chatChannelVM_channelIsUpdated() {
// Given
let cid = ChannelId.unique
let initialChannel = ChatChannel.mock(cid: cid)
let channelController = makeChannelController()
channelController.channel_mock = initialChannel
let viewModel = ChatChannelViewModel(channelController: channelController)
XCTAssertEqual(initialChannel, viewModel.channel)

// When
let updatedChannel = ChatChannel.mock(cid: cid)
channelController.channel_mock = updatedChannel
channelController.delegate?.channelController(
channelController,
didUpdateChannel: .update(updatedChannel)
)

// Then
XCTAssertEqual(updatedChannel, viewModel.channel)
}

func test_chatChannelVM_messagesLoaded() {
// Given
let channelController = makeChannelController()
Expand Down
Loading