Skip to content

Commit 4acec4f

Browse files
committed
Fix concurrently mutating warnings
1 parent 8f02dbb commit 4acec4f

File tree

22 files changed

+63
-63
lines changed

22 files changed

+63
-63
lines changed

Sources/StreamChat/APIClient/CDNClient/CDNClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public protocol CDNClient: Sendable {
5858
/// - completion: Returns an error in case the delete operation fails.
5959
func deleteAttachment(
6060
remoteUrl: URL,
61-
completion: @escaping (Error?) -> Void
61+
completion: @escaping @Sendable (Error?) -> Void
6262
)
6363
}
6464

@@ -159,7 +159,7 @@ final class StreamCDNClient: CDNClient, @unchecked Sendable {
159159

160160
func deleteAttachment(
161161
remoteUrl: URL,
162-
completion: @escaping (Error?) -> Void
162+
completion: @escaping @Sendable (Error?) -> Void
163163
) {
164164
let isImage = AttachmentFileType(ext: remoteUrl.pathExtension).isImage
165165
let endpoint = Endpoint<EmptyResponse>

Sources/StreamChat/ChatClient.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ public class ChatClient: @unchecked Sendable {
677677
/// - completion: called when the attachment is uploaded.
678678
public func uploadAttachment(
679679
localUrl: URL,
680-
progress: ((Double) -> Void)?,
681-
completion: @escaping (Result<UploadedFile, Error>) -> Void
680+
progress: (@Sendable (Double) -> Void)?,
681+
completion: @escaping @Sendable (Result<UploadedFile, Error>) -> Void
682682
) {
683683
let uploadingState: AttachmentUploadingState
684684

@@ -713,7 +713,7 @@ public class ChatClient: @unchecked Sendable {
713713
/// - completion: Returns an error in case the delete operation fails.
714714
public func deleteAttachment(
715715
remoteUrl: URL,
716-
completion: @escaping (Error?) -> Void
716+
completion: @escaping @Sendable (Error?) -> Void
717717
) {
718718
apiClient.cdnClient.deleteAttachment(
719719
remoteUrl: remoteUrl,

Sources/StreamChat/Controllers/ChannelController/ChannelController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ public class ChatChannelController: DataController, DelegateCallable, DataStoreP
13611361
/// - Parameters:
13621362
/// - timestamp: The timestamp used to find the first message to mark as unread. All messages created after this timestamp will be marked as unread.
13631363
/// - completion: The completion handler to be called after marking messages as unread. Called with a `Result` containing the updated `ChatChannel` on success, or an `Error` on failure.
1364-
public func markUnread(from timestamp: Date, completion: ((Result<ChatChannel, Error>) -> Void)? = nil) {
1364+
public func markUnread(from timestamp: Date, completion: (@Sendable (Result<ChatChannel, Error>) -> Void)? = nil) {
13651365
/// Perform action only if channel is already created on backend side and have a valid `cid`.
13661366
guard let channel = channel else {
13671367
let error = ClientError.ChannelNotCreatedYet()

Sources/StreamChat/Database/DatabaseSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extension NSManagedObjectContext: DatabaseSession {
88
private static let chatClientConfigKey = "io.getStream.StreamChat.config.key"
99

1010
var chatClientConfig: ChatClientConfig? {
11-
var config: ChatClientConfig?
11+
nonisolated(unsafe) var config: ChatClientConfig?
1212
performAndWait {
1313
config = userInfo[Self.chatClientConfigKey] as? ChatClientConfig
1414
}

Sources/StreamChat/Repositories/AuthenticationRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class AuthenticationRepository: @unchecked Sendable {
117117

118118
/// Fetches the user saved in the database, if exists
119119
func fetchCurrentUser() {
120-
var currentUserId: UserId?
120+
nonisolated(unsafe) var currentUserId: UserId?
121121

122122
databaseContainer.backgroundReadOnlyContext.performAndWait {
123123
currentUserId = databaseContainer.backgroundReadOnlyContext.currentUser?.user.id

Sources/StreamChat/Repositories/SyncRepository.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ class SyncRepository: @unchecked Sendable {
264264
)
265265
}
266266

267-
private func getUser(completion: @escaping (CurrentUserDTO?) -> Void) {
268-
var user: CurrentUserDTO?
267+
private func getUser(completion: @escaping @Sendable (CurrentUserDTO?) -> Void) {
268+
nonisolated(unsafe) var user: CurrentUserDTO?
269269
database.backgroundReadOnlyContext.perform {
270270
user = self.database.backgroundReadOnlyContext.currentUser
271271
completion(user)

Sources/StreamChat/WebSocketClient/Events/Event.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public protocol HasUnreadCount: Event {
4141

4242
/// A protocol for any `MemberEvent` where it has a `member`, and `channel` payload.
4343
public protocol MemberEvent: Event {
44-
var memberUserId: UserId { get }
4544
var cid: ChannelId { get }
4645
}
4746

Sources/StreamChat/WebSocketClient/Events/UserEvents.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public final class UserGloballyBannedEvent: Event {
148148
}
149149
}
150150

151-
class UserGloballyBannedEventDTO: EventDTO {
151+
final class UserGloballyBannedEventDTO: EventDTO {
152152
let user: UserPayload
153153
let createdAt: Date
154154
let payload: EventPayload
@@ -253,7 +253,7 @@ public final class UserGloballyUnbannedEvent: Event {
253253
}
254254
}
255255

256-
class UserGloballyUnbannedEventDTO: EventDTO {
256+
final class UserGloballyUnbannedEventDTO: EventDTO {
257257
let user: UserPayload
258258
let createdAt: Date
259259
let payload: EventPayload

Sources/StreamChat/Workers/Background/MessageSender.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MessageSender: Worker, @unchecked Sendable {
7373

7474
func handleChanges(changes: [ListChange<MessageDTO>]) {
7575
// Convert changes to a dictionary of requests by their cid
76-
var newRequests: [ChannelId: [MessageSendingQueue.SendRequest]] = [:]
76+
nonisolated(unsafe) var newRequests: [ChannelId: [MessageSendingQueue.SendRequest]] = [:]
7777
changes.forEach { change in
7878
switch change {
7979
case .insert(let dto, index: _), .update(let dto, index: _):

TestTools/StreamChatTestTools/Mocks/StreamChat/ChatClient_Mock.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ extension ChatClient {
146146
requestEncoder: $1,
147147
requestDecoder: $2,
148148
attachmentDownloader: $3,
149-
attachmentUploader: $4
149+
attachmentUploader: $4,
150+
cdnClient: $5
150151
)
151152
},
152153
webSocketClientBuilder: {
@@ -296,7 +297,8 @@ extension ChatClient.Environment {
296297
requestEncoder: $1,
297298
requestDecoder: $2,
298299
attachmentDownloader: $3,
299-
attachmentUploader: $4
300+
attachmentUploader: $4,
301+
cdnClient: $5
300302
)
301303
},
302304
webSocketClientBuilder: {

0 commit comments

Comments
 (0)