From d24f17cc4b7f2c1056f77508fa62f6e6a2c126d0 Mon Sep 17 00:00:00 2001 From: "lucas.nguyen" Date: Tue, 18 Nov 2025 14:35:55 +0700 Subject: [PATCH 1/2] Add the `maxGalleryAssetsCount` to the composer config to limit the maximum number of assets to be fetched from the gallery. --- .../ChatChannel/Composer/ComposerConfig.swift | 3 +++ .../ChatChannel/Composer/MessageComposerViewModel.swift | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerConfig.swift b/Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerConfig.swift index 0eb5a7b2b..0c4e995fe 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerConfig.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerConfig.swift @@ -13,6 +13,7 @@ public struct ComposerConfig { public var inputViewCornerRadius: CGFloat public var inputFont: UIFont public var gallerySupportedTypes: GallerySupportedTypes + public var maxGalleryAssetsCount: Int? public var inputPaddingsConfig: PaddingsConfig public var adjustMessageOnSend: (String) -> (String) public var adjustMessageOnRead: (String) -> (String) @@ -33,6 +34,7 @@ public struct ComposerConfig { inputViewCornerRadius: CGFloat = 20, inputFont: UIFont = UIFont.preferredFont(forTextStyle: .body), gallerySupportedTypes: GallerySupportedTypes = .imagesAndVideo, + maxGalleryAssetsCount: Int? = nil, inputPaddingsConfig: PaddingsConfig = .composerInput, adjustMessageOnSend: @escaping (String) -> (String) = { $0 }, adjustMessageOnRead: @escaping (String) -> (String) = { $0 }, @@ -47,6 +49,7 @@ public struct ComposerConfig { self.adjustMessageOnRead = adjustMessageOnRead self.attachmentPayloadConverter = attachmentPayloadConverter self.gallerySupportedTypes = gallerySupportedTypes + self.maxGalleryAssetsCount = maxGalleryAssetsCount self.inputPaddingsConfig = inputPaddingsConfig self.isVoiceRecordingEnabled = isVoiceRecordingEnabled } diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift b/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift index 813e7796e..69b425b2c 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift @@ -689,6 +689,9 @@ open class MessageComposerViewModel: ObservableObject { fetchOptions.predicate = predicate } fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)] + if let maxGalleryAssetsCount = utils.composerConfig.maxGalleryAssetsCount { + fetchOptions.fetchLimit = maxGalleryAssetsCount + } let assets = PHAsset.fetchAssets(with: fetchOptions) DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak self] in self?.imageAssets = assets From 298e18b4bc4db0fd1ea180049ec21ba50e9b3efb Mon Sep 17 00:00:00 2001 From: "lucas.nguyen" Date: Tue, 25 Nov 2025 10:23:13 +0700 Subject: [PATCH 2/2] Update CHANGELOG file --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 091ab6a68..1c93bca6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). # Upcoming ### ✅ Added +- Add the `maxGalleryAssetsCount` to the composer config [#1053](https://github.com/GetStream/stream-chat-swiftui/pull/1053) - Expose `QuotedMessageViewContainer` [#1056](https://github.com/GetStream/stream-chat-swiftui/pull/1056) - Add `QuotedMessageContentView` and `ViewFactory.makeQuotedMessageContentView()` [#1056](https://github.com/GetStream/stream-chat-swiftui/pull/1056) - Allow customizing the attachment size and avatar size of the quoted message view [#1056](https://github.com/GetStream/stream-chat-swiftui/pull/1056)