Skip to content

Commit 1091c9f

Browse files
authored
Add the maxGalleryAssetsCount to the composer config (#1053)
1 parent 0081b60 commit 1091c9f

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44
# Upcoming
55

66
### ✅ Added
7+
- Add the `maxGalleryAssetsCount` to the composer config [#1053](https://github.com/GetStream/stream-chat-swiftui/pull/1053)
78
- Expose `QuotedMessageViewContainer` [#1056](https://github.com/GetStream/stream-chat-swiftui/pull/1056)
89
- Add `QuotedMessageContentView` and `ViewFactory.makeQuotedMessageContentView()` [#1056](https://github.com/GetStream/stream-chat-swiftui/pull/1056)
910
- Allow customizing the attachment size and avatar size of the quoted message view [#1056](https://github.com/GetStream/stream-chat-swiftui/pull/1056)

Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerConfig.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public struct ComposerConfig {
1313
public var inputViewCornerRadius: CGFloat
1414
public var inputFont: UIFont
1515
public var gallerySupportedTypes: GallerySupportedTypes
16+
public var maxGalleryAssetsCount: Int?
1617
public var inputPaddingsConfig: PaddingsConfig
1718
public var adjustMessageOnSend: (String) -> (String)
1819
public var adjustMessageOnRead: (String) -> (String)
@@ -33,6 +34,7 @@ public struct ComposerConfig {
3334
inputViewCornerRadius: CGFloat = 20,
3435
inputFont: UIFont = UIFont.preferredFont(forTextStyle: .body),
3536
gallerySupportedTypes: GallerySupportedTypes = .imagesAndVideo,
37+
maxGalleryAssetsCount: Int? = nil,
3638
inputPaddingsConfig: PaddingsConfig = .composerInput,
3739
adjustMessageOnSend: @escaping (String) -> (String) = { $0 },
3840
adjustMessageOnRead: @escaping (String) -> (String) = { $0 },
@@ -47,6 +49,7 @@ public struct ComposerConfig {
4749
self.adjustMessageOnRead = adjustMessageOnRead
4850
self.attachmentPayloadConverter = attachmentPayloadConverter
4951
self.gallerySupportedTypes = gallerySupportedTypes
52+
self.maxGalleryAssetsCount = maxGalleryAssetsCount
5053
self.inputPaddingsConfig = inputPaddingsConfig
5154
self.isVoiceRecordingEnabled = isVoiceRecordingEnabled
5255
}

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,9 @@ open class MessageComposerViewModel: ObservableObject {
689689
fetchOptions.predicate = predicate
690690
}
691691
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
692+
if let maxGalleryAssetsCount = utils.composerConfig.maxGalleryAssetsCount {
693+
fetchOptions.fetchLimit = maxGalleryAssetsCount
694+
}
692695
let assets = PHAsset.fetchAssets(with: fetchOptions)
693696
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak self] in
694697
self?.imageAssets = assets

0 commit comments

Comments
 (0)