@@ -130,6 +130,9 @@ open class MessageComposerViewModel: ObservableObject {
130
130
131
131
private var timer : Timer ?
132
132
private var cooldownPeriod = 0
133
+ private var isSlowModeDisabled : Bool {
134
+ channelController. channel? . ownCapabilities. contains ( " skip-slow-mode " ) == true
135
+ }
133
136
134
137
private var cancellables = Set < AnyCancellable > ( )
135
138
private lazy var commandsHandler = utils
@@ -442,7 +445,7 @@ open class MessageComposerViewModel: ObservableObject {
442
445
443
446
private func fetchAssets( ) {
444
447
let fetchOptions = PHFetchOptions ( )
445
- let supportedTypes = self . utils. composerConfig. gallerySupportedTypes
448
+ let supportedTypes = utils. composerConfig. gallerySupportedTypes
446
449
var predicate : NSPredicate ?
447
450
if supportedTypes == . images {
448
451
predicate = NSPredicate ( format: " mediaType = \( PHAssetMediaType . image. rawValue) " )
@@ -557,6 +560,7 @@ open class MessageComposerViewModel: ObservableObject {
557
560
558
561
private func listenToCooldownUpdates( ) {
559
562
channelController. channelChangePublisher. sink { [ weak self] _ in
563
+ guard self ? . isSlowModeDisabled == false else { return }
560
564
let cooldownDuration = self ? . channelController. channel? . cooldownDuration ?? 0
561
565
if self ? . cooldownPeriod == cooldownDuration {
562
566
return
@@ -569,7 +573,7 @@ open class MessageComposerViewModel: ObservableObject {
569
573
570
574
private func checkChannelCooldown( ) {
571
575
let duration = channelController. channel? . cooldownDuration ?? 0
572
- if duration > 0 && timer == nil {
576
+ if duration > 0 && timer == nil && !isSlowModeDisabled {
573
577
cooldownDuration = duration
574
578
timer = Timer . scheduledTimer (
575
579
withTimeInterval: 1 ,
@@ -621,7 +625,7 @@ open class MessageComposerViewModel: ObservableObject {
621
625
@objc
622
626
private func applicationWillEnterForeground( ) {
623
627
if ( imageAssets? . count ?? 0 ) > 0 {
624
- self . fetchAssets ( )
628
+ fetchAssets ( )
625
629
}
626
630
}
627
631
}
0 commit comments