Skip to content

Commit f9752d7

Browse files
Fixed data race when channels are updated from message list
1 parent c23ce15 commit f9752d7

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1313

1414
### 🐞 Fixed
1515
- Channel header sometimes blinks when many messages are sent
16+
- Data race when channels are updated from message list
1617

1718
# [4.20.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.20.0)
1819
_August 04, 2022_

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListViewModel.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,10 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
6666
}
6767
if newValue == nil {
6868
selectedChannelIndex = nil
69-
} else {
70-
DispatchQueue.global(qos: .default).async { [weak self] in
71-
guard let self = self else { return }
72-
self.selectedChannelIndex = self.channels.firstIndex(where: { channel in
73-
channel.cid.rawValue == self.selectedChannel?.channel.cid.rawValue
74-
})
75-
}
69+
} else if utils.messageListConfig.updateChannelsFromMessageList {
70+
selectedChannelIndex = channels.firstIndex(where: { channel in
71+
channel.cid.rawValue == newValue?.channel.cid.rawValue
72+
})
7673
}
7774
}
7875
}

0 commit comments

Comments
 (0)