-
Notifications
You must be signed in to change notification settings - Fork 98
Swift 6: complete concurrency checking #825
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
base: develop
Are you sure you want to change the base?
Changes from all commits
ddf78cc
b73c9c5
2f64d75
87292cf
ab7356d
391b156
26dd6aa
ef3bbc0
bb0ed90
87fcb5a
994196f
4c94da4
6b78288
8eae0dd
6e1e8c9
f10725c
c0b9111
79ef1c1
e28503d
f8d9504
fa2872a
4b305c5
1ab09e2
1170a52
7a0cfe3
7d0237c
9769ff4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,7 @@ struct AppleMessageComposerView<Factory: ViewFactory>: View, KeyboardReadable { | |
} | ||
) | ||
.offset(y: -composerHeight) | ||
.animation(nil) : nil, | ||
.animation(.none, value: viewModel.showCommandsOverlay) : nil, | ||
alignment: .bottom | ||
) | ||
.modifier(factory.makeComposerViewModifier()) | ||
|
@@ -214,7 +214,7 @@ struct BlurredBackground: View { | |
} | ||
|
||
struct HeightPreferenceKey: PreferenceKey { | ||
static var defaultValue: CGFloat? = nil | ||
static let defaultValue: CGFloat? = nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this causing issues somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
static func reduce(value: inout CGFloat?, nextValue: () -> CGFloat?) { | ||
value = value ?? nextValue() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ import StreamChatSwiftUI | |
import SwiftUI | ||
|
||
struct ChooseChannelQueryView: View { | ||
static let queryIdentifiers = ChannelListQueryIdentifier.allCases.sorted(using: KeyPathComparator(\.title)) | ||
static var queryIdentifiers: [ChannelListQueryIdentifier] { | ||
ChannelListQueryIdentifier.allCases.sorted(by: { $0.title < $1.title }) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was giving Sendable related error which did not feel right. Just switched to another sorting method. |
||
|
||
var body: some View { | ||
ForEach(Self.queryIdentifiers) { queryIdentifier in | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import StreamChat | |
import StreamChatSwiftUI | ||
import SwiftUI | ||
|
||
class NewChatViewModel: ObservableObject, ChatUserSearchControllerDelegate { | ||
@MainActor class NewChatViewModel: ObservableObject, ChatUserSearchControllerDelegate { | ||
|
||
@Injected(\.chatClient) var chatClient | ||
|
||
|
@@ -99,31 +99,37 @@ class NewChatViewModel: ObservableObject, ChatUserSearchControllerDelegate { | |
if !loadingNextUsers { | ||
loadingNextUsers = true | ||
searchController.loadNextUsers(limit: 50) { [weak self] _ in | ||
guard let self = self else { return } | ||
self.chatUsers = self.searchController.userArray | ||
self.loadingNextUsers = false | ||
Task { @MainActor in | ||
guard let self = self else { return } | ||
self.chatUsers = self.searchController.userArray | ||
self.loadingNextUsers = false | ||
} | ||
} | ||
} | ||
} | ||
|
||
// MARK: - ChatUserSearchControllerDelegate | ||
|
||
func controller( | ||
nonisolated func controller( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we avoid this being nonisolated in the LLC? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Summary is that nonisolated can be avoided if view models are not |
||
_ controller: ChatUserSearchController, | ||
didChangeUsers changes: [ListChange<ChatUser>] | ||
) { | ||
chatUsers = controller.userArray | ||
Task { @MainActor in | ||
chatUsers = controller.userArray | ||
} | ||
} | ||
|
||
// MARK: - private | ||
|
||
private func searchUsers(with term: String?) { | ||
state = .loading | ||
searchController.search(term: term) { [weak self] error in | ||
if error != nil { | ||
self?.state = .error | ||
} else { | ||
self?.state = .loaded | ||
Task { @MainActor in | ||
if error != nil { | ||
self?.state = .error | ||
} else { | ||
self?.state = .loaded | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -137,13 +143,15 @@ class NewChatViewModel: ObservableObject, ChatUserSearchControllerDelegate { | |
extraData: [:] | ||
) | ||
channelController?.synchronize { [weak self] error in | ||
if error != nil { | ||
self?.state = .error | ||
self?.updatingSelectedUsers = false | ||
} else { | ||
withAnimation { | ||
self?.state = .channel | ||
Task { @MainActor in | ||
if error != nil { | ||
self?.state = .error | ||
self?.updatingSelectedUsers = false | ||
} else { | ||
withAnimation { | ||
self?.state = .channel | ||
self?.updatingSelectedUsers = false | ||
} | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import StreamChat | |
import StreamChatSwiftUI | ||
import SwiftUI | ||
|
||
class LoginViewModel: ObservableObject { | ||
@MainActor class LoginViewModel: ObservableObject { | ||
|
||
@Published var demoUsers = UserCredentials.builtInUsers | ||
@Published var loading = false | ||
|
@@ -42,7 +42,7 @@ class LoginViewModel: ObservableObject { | |
return | ||
} | ||
|
||
DispatchQueue.main.async { [weak self] in | ||
Task { @MainActor [weak self] in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DispatchQueue gives Sendable error for self There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we should use Task going forward |
||
withAnimation { | ||
self?.loading = false | ||
UnsecureRepository.shared.save(user: credentials) | ||
|
@@ -64,7 +64,7 @@ class LoginViewModel: ObservableObject { | |
return | ||
} | ||
|
||
DispatchQueue.main.async { [weak self] in | ||
Task { @MainActor [weak self] in | ||
withAnimation { | ||
self?.loading = false | ||
AppState.shared.userState = .loggedIn | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xcode 15 builds are going away, disabling it for now and a cleanup happens separately