Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageView not hiding #113

Closed
krakowski opened this issue Aug 14, 2017 · 4 comments
Closed

MessageView not hiding #113

krakowski opened this issue Aug 14, 2017 · 4 comments

Comments

@krakowski
Copy link

Calling SwiftMessages.hideAll() directly after showing a dialog won't hide it.

This should reproduce the issue:

var config = SwiftMessages.Config()
config.duration = .forever

let view = MessageView.viewFromNib(layout: .CardView)
SwiftMessages.show(config: config, view: view)
SwiftMessages.hideAll()

I know this piece of code effectively does nothing. In my case I wait for an event and hide the dialog afterwards. Unfortunately, this seems to happen too fast. It looks like some time has to go by before I can hide the dialog.

@TwinkyDaniel
Copy link

I have basically the same problem. I am showing a deferred message and want to replace it with another message. I think the problem is the invoke into the main dispatch queue when showing and not invoking when hiding. At the end of the day hiding will hide nothing because the show call is still inside the queue.

@wtmoose
Copy link
Member

wtmoose commented Aug 15, 2017

@filkra @TwinkyDaniel thanks for bringing this up. Would you mind taking a look at the head of developer and let me know if this works for you?

With this fix, calling show immediately followed by hide results in the message being displayed very briefly. This is due to the message queue being managed asynchronously on a background queue.

In order to have the message not display at all, I would need to eliminate the background queue, requiring all SwiftMessages calls to be made on the main queue. This is probably how it should have been done in the first place, but given that it's a backward incompatible change, I'm inclined to leave the background queue in place.

I'm interested to hear your thoughts.

@TwinkyDaniel
Copy link

The fix works for my issue. Thanks for the quick response! I was previously using CSNotificationView and switched to your library a few days ago. Your library is working a lot better and has better features. Thumbs up for that great work ;-)

Regarding the background queue: I wouldn't mind having to schedule all messages on the main thread since this is a concept that's present in the majority of ui libraries. But I can also see the reason to have the ability to send a message from anywhere without thinking about threading and queues. If you want to support both without breaking changes, maybe have 2 different sets of methods?

@wtmoose
Copy link
Member

wtmoose commented Sep 6, 2017

3.5.0

@wtmoose wtmoose closed this as completed Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants