@@ -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