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

Option to disable the visibilitychange event listener #103

Open
ForrestFire0 opened this issue Jul 21, 2024 · 4 comments
Open

Option to disable the visibilitychange event listener #103

ForrestFire0 opened this issue Jul 21, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@ForrestFire0
Copy link

My application is receiving notifications from a server. I push a toast... but if the user leaves the page in the background, the notifications pile up and are excessive when returning. I would like the ability to disable the notification. (Without changing the source code of your library, that is...) The user expects missed notifications to show up in the notification tray but that is another part of the application.

Also, if there is a little snippet of code I could insert in the meantime to my app to get this behavior... that would be great. Maybe modifying the event listeners of document? But since the visibility check is made when the components are created, this would only work for components created when the document is visible.

If you want a pull request I could probably finagle one...

@zerodevx
Copy link
Owner

Hmm if you add a visiblity check condition before pushing the toast, does that meet your requirements? Like:

if (!document.hidden) toast.push('The Message')

@ForrestFire0
Copy link
Author

This would fix some. The other case is when some notifications come in while the user is looking, but then are paused until the user comes back. In the case where the user gets a message like "robot A disconnected", they see the little blue line ticking down, they might be confused when they come back to the window and see the same notification again. (They might think robot A disconnected a 2nd time)

@ForrestFire0
Copy link
Author

Also, if say "robot A disconnected", the user expects that notification to persist for the 3 seconds it typically does. If they know the robot disconnects, but don't see it because they returned to the app too quickly, that could be confusing.

@zerodevx
Copy link
Owner

Agree that visibilitychange should be configurable. A setting should be exposed that allows it to be disabled.

I've been waiting for Svelte 5 to land on stable (so I can rewrite the store for performance) but that's taking awhile. I think I'll work on cutting a new release first and add this feature.

@zerodevx zerodevx added the enhancement New feature or request label Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants