-
Notifications
You must be signed in to change notification settings - Fork 228
V5: Fix build warnings #3904
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: v5
Are you sure you want to change the base?
V5: Fix build warnings #3904
Changes from all commits
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 |
|---|---|---|
|
|
@@ -115,30 +115,6 @@ public struct ChatClientConfig: Sendable { | |
| /// A component that can be used to change an attachment which was successfully uploaded. | ||
| public var uploadedAttachmentPostProcessor: UploadedAttachmentPostProcessor? | ||
|
|
||
| /// Returns max possible attachment size in bytes. | ||
| /// By default the value is taken from `CDNClient.maxAttachmentSize` type. | ||
| /// But it can be overridden by setting a value here. | ||
| @available(*, deprecated, message: "The max attachment size can now be set from the Stream's Dashboard App Settings. It supports setting a size limit per attachment type.") | ||
| public var maxAttachmentSize: Int64 { | ||
| // TODO: For v5 the maxAttachmentSize should be responsibility of the UI SDK. | ||
| // Since this is not even used in the StreamChat LLC SDK. | ||
| get { | ||
| if let overrideMaxAttachmentSize = self.overrideMaxAttachmentSize { | ||
| return overrideMaxAttachmentSize | ||
| } else if let customCDNClient = customCDNClient { | ||
| return type(of: customCDNClient).maxAttachmentSize | ||
| } else { | ||
| return StreamCDNClient.maxAttachmentSize | ||
| } | ||
| } | ||
| set { | ||
| overrideMaxAttachmentSize = newValue | ||
| } | ||
| } | ||
|
|
||
| /// Used to override the maxAttachmentSize, by setting the value in the config instead of relying on `CDNClient`. | ||
| private var overrideMaxAttachmentSize: Int64? | ||
|
Comment on lines
-118
to
-140
Member
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. Awesome 🗑️ |
||
|
|
||
| /// Returns max number of attachments that can be attached to a message. | ||
| /// | ||
| /// The current limit on the backend is `30`. You can only configure a value below `30`. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,3 +38,23 @@ public struct ChatThread: Identifiable, Sendable { | |
| /// The custom data of the thread. | ||
| public let extraData: [String: RawJSON] | ||
| } | ||
|
|
||
| extension ChatThread: Hashable { | ||
|
Contributor
Author
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. Moved it from UI |
||
| public static func == (lhs: ChatThread, rhs: ChatThread) -> Bool { | ||
| lhs.parentMessageId == rhs.parentMessageId && | ||
| lhs.updatedAt == rhs.updatedAt && | ||
| lhs.title == rhs.title && | ||
| lhs.reads == rhs.reads && | ||
| lhs.latestReplies == rhs.latestReplies && | ||
| lhs.lastMessageAt == rhs.lastMessageAt && | ||
| lhs.channel == rhs.channel && | ||
| lhs.participantCount == rhs.participantCount && | ||
| lhs.replyCount == rhs.replyCount && | ||
| lhs.threadParticipants == rhs.threadParticipants && | ||
| lhs.extraData == rhs.extraData | ||
| } | ||
|
|
||
| public func hash(into hasher: inout Hasher) { | ||
| hasher.combine(parentMessageId) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,10 +22,23 @@ class MessageSender: Worker, @unchecked Sendable { | |
| @Atomic private var sendingQueueByCid: [ChannelId: MessageSendingQueue] = [:] | ||
| private var continuations = [MessageId: CheckedContinuation<ChatMessage, Error>]() | ||
|
|
||
| private lazy var observer = StateLayerDatabaseObserver<ListResult, MessageDTO, MessageDTO>( | ||
| context: self.database.backgroundReadOnlyContext, | ||
| fetchRequest: MessageDTO | ||
| .messagesPendingSendFetchRequest() | ||
| private lazy var observer = StateLayerDatabaseObserver<ListResult, MessageSendingQueue.SendRequest, MessageDTO>( | ||
|
Contributor
Author
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. Makes sense to convert earlier, also makes sure DTOs don't escape from context's thread |
||
| database: database, | ||
| fetchRequest: MessageDTO.messagesPendingSendFetchRequest(), | ||
| itemCreator: { dto in | ||
| let cid: ChannelId = { | ||
| if let rawValue = dto.channel?.cid, let cid = try? ChannelId(cid: rawValue) { | ||
| return cid | ||
| } | ||
| return ChannelId(type: .messaging, id: "") | ||
| }() | ||
| return .init( | ||
| messageId: dto.id, | ||
| cid: cid, | ||
| createdLocallyAt: (dto.locallyCreatedAt ?? dto.createdAt).bridgeDate | ||
| ) | ||
| }, | ||
| itemReuseKeyPaths: nil | ||
| ) | ||
|
|
||
| private let sendingDispatchQueue: DispatchQueue = .init( | ||
|
|
@@ -71,26 +84,17 @@ class MessageSender: Worker, @unchecked Sendable { | |
| } | ||
| } | ||
|
|
||
| func handleChanges(changes: [ListChange<MessageDTO>]) { | ||
| private func handleChanges(changes: [ListChange<MessageSendingQueue.SendRequest>]) { | ||
| // Convert changes to a dictionary of requests by their cid | ||
| nonisolated(unsafe) var newRequests: [ChannelId: [MessageSendingQueue.SendRequest]] = [:] | ||
| changes.forEach { change in | ||
| switch change { | ||
| case .insert(let dto, index: _), .update(let dto, index: _): | ||
| database.backgroundReadOnlyContext.performAndWait { | ||
| guard let cid = dto.channel.map({ try? ChannelId(cid: $0.cid) }) else { | ||
| log.error("Skipping sending of the message \(dto.id) because the channel info is missing.") | ||
| return | ||
| } | ||
| // Create the array if it didn't exist | ||
| guard let cid = cid else { return } | ||
| newRequests[cid] = newRequests[cid] ?? [] | ||
| newRequests[cid]!.append(.init( | ||
| messageId: dto.id, | ||
| cid: cid, | ||
| createdLocallyAt: (dto.locallyCreatedAt ?? dto.createdAt).bridgeDate | ||
| )) | ||
| } | ||
| case .insert(let request, index: _), .update(let request, index: _): | ||
| // Create the array if it didn't exist | ||
| let cid = request.cid | ||
| guard !cid.id.isEmpty else { return } | ||
| newRequests[cid] = newRequests[cid] ?? [] | ||
| newRequests[cid]!.append(request) | ||
| case .move, .remove: | ||
| break | ||
| } | ||
|
|
||
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.
This was interesting because DTOs were leaking outside of context's queue
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.
Interesting... Could this be causing this crash: #3905?
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.
We might need to fix this on v4 as well