Skip to content

Commit 78bca05

Browse files
Removed atomic from the codebase
1 parent 45383a7 commit 78bca05

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

DemoAppSwiftUI/NewChatViewModel.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class NewChatViewModel: ObservableObject, ChatUserSearchControllerDelegate {
2121
@Published var state: NewChatState = .initial
2222
@Published var selectedUsers = [ChatUser]() {
2323
didSet {
24-
if _updatingSelectedUsers.compareAndSwap(old: false, new: true) {
24+
if !updatingSelectedUsers {
25+
updatingSelectedUsers = true
2526
if !selectedUsers.isEmpty {
2627
do {
2728
try makeChannelController()
@@ -40,8 +41,8 @@ class NewChatViewModel: ObservableObject, ChatUserSearchControllerDelegate {
4041
}
4142
}
4243

43-
@Atomic private var loadingNextUsers: Bool = false
44-
@Atomic private var updatingSelectedUsers: Bool = false
44+
private var loadingNextUsers: Bool = false
45+
private var updatingSelectedUsers: Bool = false
4546

4647
var channelController: ChatChannelController?
4748

@@ -95,7 +96,8 @@ class NewChatViewModel: ObservableObject, ChatUserSearchControllerDelegate {
9596
return
9697
}
9798

98-
if _loadingNextUsers.compareAndSwap(old: false, new: true) {
99+
if !loadingNextUsers {
100+
loadingNextUsers = true
99101
searchController.loadNextUsers(limit: 50) { [weak self] _ in
100102
guard let self = self else { return }
101103
self.chatUsers = self.searchController.users

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListViewModel.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
3333
private var timer: Timer?
3434

3535
/// Controls loading the channels.
36-
@Atomic private var loadingNextChannels: Bool = false
36+
private var loadingNextChannels: Bool = false
3737

3838
/// Published variables.
3939
@Published public var channels = LazyCachedMapCollection<ChatChannel>() {
@@ -127,7 +127,8 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
127127
return
128128
}
129129

130-
if _loadingNextChannels.compareAndSwap(old: false, new: true) {
130+
if !loadingNextChannels {
131+
loadingNextChannels = true
131132
controller?.loadNextChannels { [weak self] _ in
132133
guard let self = self else { return }
133134
self.loadingNextChannels = false
@@ -145,7 +146,8 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
145146
return
146147
}
147148

148-
if _loadingNextChannels.compareAndSwap(old: false, new: true) {
149+
if !loadingNextChannels {
150+
loadingNextChannels = true
149151
messageSearchController.loadNextMessages { [weak self] _ in
150152
guard let self = self else { return }
151153
self.loadingNextChannels = false

0 commit comments

Comments
 (0)