mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:23:25 +08: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(
|
||||
self.clients.matchAll().then(function(clients) {
|
||||
const activeClient = clients.find(client => client.focused) || clients.find(client => client.visibilityState === "visible");
|
||||
|
||||
clients.forEach(function(client) {
|
||||
client.postMessage({
|
||||
primaryTab: client.focused
|
||||
primaryTab: client.id === activeClient?.id
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user