Skip to content

Commit

Permalink
Fix channel list state views not updating when the view is not visible (
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-vieira authored Oct 31, 2024
1 parent c25892d commit 835dba7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## StreamChatUI
### ✅ Added
- Open `shouldMarkThreadRead` and `shouldMarkChannelRead` [#3468](https://github.com/GetStream/stream-chat-swift/pull/3468)
### 🐞 Fixed
- Fix channel list state views not updating when the view is not visible [#3479](https://github.com/GetStream/stream-chat-swift/pull/3479)

# [4.65.0](https://github.com/GetStream/stream-chat-swift/releases/tag/4.65.0)
_October 18, 2024_
Expand Down
4 changes: 3 additions & 1 deletion Sources/StreamChatUI/ChatChannelList/ChatChannelListVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,14 @@ open class ChatChannelListVC: _ViewController,
_ controller: ChatChannelListController,
didChangeChannels changes: [ListChange<ChatChannel>]
) {
handleStateChanges(controller.state)

if skipChannelUpdates {
skippedRendering = true
return
}

reloadChannels()
handleStateChanges(controller.state)
}

// MARK: - DataControllerStateDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ final class ChatChannelListVC_Tests: XCTestCase {
XCTAssertEqual(channelListVC.skippedRendering, true)
}

func test_didChangeChannels_whenIsNotVisible_shouldStillUpdateStateViews() {
mockedChannelListController.channels_mock = [.mock(cid: .unique)]
mockedChannelListController.state_mock = .remoteDataFetched
let channelListVC = FakeChatChannelListVC()
channelListVC.components.isChatChannelListStatesEnabled = true
channelListVC.controller = mockedChannelListController
channelListVC.shouldMockViewIfLoaded = false
channelListVC.emptyView.isHidden = false

channelListVC.controller(mockedChannelListController, didChangeChannels: [])

XCTAssertEqual(channelListVC.emptyView.isHidden, true)
XCTAssertEqual(channelListVC.mockedCollectionView.performBatchUpdatesCallCount, 0)
XCTAssertEqual(channelListVC.mockedCollectionView.reloadDataCallCount, 0)
}

func test_didChangeChannels_whenEmptyViewVisible_whenNewChannelsNotEmpty_shouldHideEmptyView() {
let channelListVC = FakeChatChannelListVC()
channelListVC.components.isChatChannelListStatesEnabled = true
Expand Down

0 comments on commit 835dba7

Please sign in to comment.