-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
foreground-service
: Listen to tab visibility change event
#1878
Conversation
Fixes openhab#1872. This makes the foreground service also listen to the `visibilitychange` event to stop and resume foreground activity when the tab is changed or the browser is closed. See https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event. Signed-off-by: Florian Hotze <[email protected]>
FYI @digitaldan |
Job #969: Bundle Size — 15.76MiB (+0.02%).Metrics (3 changes)
Total size by type (3 changes)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I'm all for avoiding things happening in the background when they're not useful, especially when the UI is used on a battery-powered device, like a phone or tablet.
Totally agreed 👍 I noticed this issue especially when using the SIP client in the iOS app: When I switched to another app, mic access stayed active. This is quite confusing and I don’t feel so good when the yellow indicator is displaying that something is listening to me. |
It was even a bigger problem for UIs that just listen to It could even be useful to close the SSE connection and resume it (with the current values) on |
With this change, will the SIP widget remain active, when the user changes the tab, and later returns? It shall stay active. |
I was not thinking about SSE when I created this PR, but very good points! I'm not sure what SSE currently does when the tab is switched, however thanks to my PRs with the toast message and the SSE reconnection mechanism I have noticed that once I leave Safari on iOS and come back, SSE has to reconnect so it seems that it is not always connected.
With this change, it will unregister when the user changes the tab, and then reconnect once he returns. As long as the user is in another tab or has closed the browser window, the SIP widget is disconnected. |
This is not good. It shall be possible to receive calls in inactive tabs and it shall be possible during a call to change the tabs. |
There are also good arguments to have that behaviour. The SIP widget is the only part of MainUI that might have a benefit from staying active in the background. If you want the ability to not have it always active, feel free to implement something. Just note that MainUI is meant to be a PWA to control openHAB and your home, it is not meant to be a phone app. |
…#1885) ... and check for foreground before starting foreground activity. Follow-up for #1878. Signed-off-by: Florian Hotze <[email protected]>
Fixes #1872.
This makes the foreground service also listen to the
visibilitychange
event to stop and resume foreground activity when the tab is changed or the browser is closed.See https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event.