SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.31k stars 743 forks source link

ignoreDuplicates is not working #328

Closed AlirezaSN closed 3 years ago

AlirezaSN commented 5 years ago

Hi, i use ignoreDuplicates property but when i call my function 10 times in a short time, just one Message appears. where did i make a mistake? :)

my call code:

DispatchQueue.main.async {
      for _ in 10.countableRange {
             Toast.show("Hi", color: .red)
      }
}

my function:

public class func show(_ message: String, color: UIColor,
                           config: SwiftMessages.Config? = nil,
                           completion: (() -> Void)? = nil) {
        let messageView = self.bundleView ?? MessageView.viewFromNib(layout: .cardView)
        let bgView = messageView.backgroundView ?? messageView
        bgView.backgroundColor = color
        messageView.configureDropShadow()
        messageView.configureContent(body: message)
        //messageView.customId = Toast.currentFullDateTimeString
        if let font = Helper.shared.fonts.first {
            messageView.bodyLabel?.font = font.withSize(15.0)
        }
        var conf = config ?? SwiftMessages.defaultConfig
        conf.presentationContext = .window(windowLevel: UIWindow.Level.normal)
        conf.eventListeners.append { event in
            if event == .didHide { completion?() }
        }
        conf.ignoreDuplicates = false
        SwiftMessages.show(config: conf, view: messageView)
}

meanwhile, the customId property is private and we can't set a dynamic string.

thanks a lot.

wtmoose commented 5 years ago

Its a bug. Thanks for letting me know.

I guess that feature isn't used much and nobody noticed until you did. If you're in a hurry, MessageView.id is writable.

AlirezaSN commented 5 years ago

i'll check it. thank you 👍👍

wtmoose commented 5 years ago

This is a bug, so leaving open

wtmoose commented 3 years ago

Should be fixed in 8.0.3