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

Add persistent toasts #36

Closed
hudochenkov opened this issue Feb 2, 2021 · 6 comments · Fixed by #37
Closed

Add persistent toasts #36

hudochenkov opened this issue Feb 2, 2021 · 6 comments · Fixed by #37
Labels
bug Something isn't working question Further information is requested

Comments

@hudochenkov
Copy link
Contributor

Sometimes we need to show toast until it's dismissed by user or programmatically. E. g. connection lost and notification is shown until it's back online. Or some long or slow process happens.

It is not always possible to use toast.promise for that. Currently I use very long duration to simulate persistent toast.

Is it possible to add persistent toast, which doesn't have any timers inside them? Then it would possible to do:

const id = toast('No connection.', { persistent: true });

toast('Connected.', { id, persistent: false })
@timolins
Copy link
Owner

timolins commented Feb 2, 2021

Would { duration: Infinity } do the trick for you? Should work well, without adding more options to the API.

@timolins timolins added the question Further information is requested label Feb 2, 2021
@hudochenkov
Copy link
Contributor Author

Just tried. Toast won't even show. I tried both my custom toast and default one.

@timolins
Copy link
Owner

timolins commented Feb 3, 2021

You are right. That's weird. I'll look into this.

Edit: This is why: denysdovhan/wtfjs#61 (comment)

Will try to find a different solution, as this seems like a valid use case.

@timolins timolins added the bug Something isn't working label Feb 3, 2021
@timolins
Copy link
Owner

timolins commented Feb 3, 2021

Does toast("Endless", { duration: -1 }) make sense to you? Was the easiest fix I can think of, not sure if it's the best API though.

@ghost
Copy link

ghost commented Feb 12, 2021

@timolins I think it would be better to just do if (!isFinite(duration)) { don't set timeout } and keep using the { duration: Infinity } API.

@timolins
Copy link
Owner

Thanks for the feedback! I agree with you, using Infinity seems like the more intuitive API. Will update and merge the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants