Skip to content

Commit 7711317

Browse files
Fix skip slow mode capability not handled (#402)
1 parent 6699693 commit 7711317

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6-
### 🔄 Changed
6+
### 🐞 Fixed
7+
- Fix skip slow mode capability not handled
78

89
# [4.42.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.42.0)
910
_November 15, 2023_

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ open class MessageComposerViewModel: ObservableObject {
130130

131131
private var timer: Timer?
132132
private var cooldownPeriod = 0
133+
private var isSlowModeDisabled: Bool {
134+
channelController.channel?.ownCapabilities.contains("skip-slow-mode") == true
135+
}
133136

134137
private var cancellables = Set<AnyCancellable>()
135138
private lazy var commandsHandler = utils
@@ -442,7 +445,7 @@ open class MessageComposerViewModel: ObservableObject {
442445

443446
private func fetchAssets() {
444447
let fetchOptions = PHFetchOptions()
445-
let supportedTypes = self.utils.composerConfig.gallerySupportedTypes
448+
let supportedTypes = utils.composerConfig.gallerySupportedTypes
446449
var predicate: NSPredicate?
447450
if supportedTypes == .images {
448451
predicate = NSPredicate(format: "mediaType = \(PHAssetMediaType.image.rawValue)")
@@ -557,6 +560,7 @@ open class MessageComposerViewModel: ObservableObject {
557560

558561
private func listenToCooldownUpdates() {
559562
channelController.channelChangePublisher.sink { [weak self] _ in
563+
guard self?.isSlowModeDisabled == false else { return }
560564
let cooldownDuration = self?.channelController.channel?.cooldownDuration ?? 0
561565
if self?.cooldownPeriod == cooldownDuration {
562566
return
@@ -569,7 +573,7 @@ open class MessageComposerViewModel: ObservableObject {
569573

570574
private func checkChannelCooldown() {
571575
let duration = channelController.channel?.cooldownDuration ?? 0
572-
if duration > 0 && timer == nil {
576+
if duration > 0 && timer == nil && !isSlowModeDisabled {
573577
cooldownDuration = duration
574578
timer = Timer.scheduledTimer(
575579
withTimeInterval: 1,
@@ -621,7 +625,7 @@ open class MessageComposerViewModel: ObservableObject {
621625
@objc
622626
private func applicationWillEnterForeground() {
623627
if (imageAssets?.count ?? 0) > 0 {
624-
self.fetchAssets()
628+
fetchAssets()
625629
}
626630
}
627631
}

0 commit comments

Comments
 (0)