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

Correctly handle not showing notifications in a service-worker friendly way #2397

Open
taoeffect opened this issue Oct 28, 2024 · 1 comment
Assignees
Labels
App:Frontend Kind:Core Anything that changes or affects the fundamental core data structures & design of the application. Kind:Enhancement Improvements, new features, performance upgrades, etc. Level:Advanced Priority:High

Comments

@taoeffect
Copy link
Member

Problem

#2394 handles not displaying notifications to the user when the user is already looking at the chat by checking the current route.

This doesn't work in the context of the service-worker, which is where gi.actions will live once #2357 is merged.

Another consideration is whether the user has been idle. Even if the user is looking at the chat screen, we may still want to play a sound if they've been idle for a sufficient period of time. We currently use idleVue to check this, but this logic isn't used in #2394.

Solution

Handle all of this in a service-worker friendly way.

@taoeffect taoeffect added Kind:Enhancement Improvements, new features, performance upgrades, etc. App:Frontend Priority:High Level:Advanced Kind:Core Anything that changes or affects the fundamental core data structures & design of the application. labels Oct 28, 2024
@corrideat
Copy link
Member

This doesn't work in the context of the service-worker, which is where gi.actions will live once #2357 is merged.

To expand on this: it doesn't work in the SW because the SW doesn't have access to the router. The SW might (I haven't checked), however, have access to the raw URLs for each client.

Handle all of this in a service-worker friendly way.

There are two ways I can think of this may be handled. Either way, since there can be several active tabs or windows open at once (e.g., two foreground windows), this probably needs to be an array in the SW.

If the SW can see its clients URLs

The SW can check each active tab URL and omit notifications. The downside of this is that we might need to hardcode the URL components, although a shared import between the UI and the SW could help.

Event-based approach

The tab could send an event to the SW telling it its active and which events to skip. If done this way, it should probably also include some kind of ping mechanism (or the SW listening to removed clients) to handle tabs that crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App:Frontend Kind:Core Anything that changes or affects the fundamental core data structures & design of the application. Kind:Enhancement Improvements, new features, performance upgrades, etc. Level:Advanced Priority:High
Projects
None yet
Development

No branches or pull requests

2 participants