mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: allow non focused tab to be primary tab in service worker (#29516)
Follow up to #29388 - when there are no clients in focus, we should take the first visible client as the primary tab.
This commit is contained in:
parent
9c17588f6a
commit
8aa4c39c3c
@ -132,9 +132,11 @@ self.addEventListener('message', function(event) {
|
|||||||
|
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
self.clients.matchAll().then(function(clients) {
|
self.clients.matchAll().then(function(clients) {
|
||||||
|
const activeClient = clients.find(client => client.focused) || clients.find(client => client.visibilityState === "visible");
|
||||||
|
|
||||||
clients.forEach(function(client) {
|
clients.forEach(function(client) {
|
||||||
client.postMessage({
|
client.postMessage({
|
||||||
primaryTab: client.focused
|
primaryTab: client.id === activeClient?.id
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user