Skip to content

Commit bd5f587

Browse files
committed
Rework focusClientWindow
1 parent fdb6432 commit bd5f587

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

example/web/twilio-sw.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ function focusClientWindow() {
110110
self.clients.matchAll({
111111
type: "window",
112112
}).then((clients) => {
113-
for (const client of clients) {
114-
if (client.url === "/" && "focus" in client) return client.focus();
115-
}
116-
if (clients.openWindow) return clients.openWindow("/");
117-
}).catch((error) => {
118-
_error('Could not focus client window', error);
113+
clients
114+
.filter(value => !value.focused)
115+
.filter(value => "focus" in value)
116+
.forEach((client) => {
117+
client.focus().catch((error) => _error('Error focusing client window', error));
118+
});
119119
});
120120
}
121121

0 commit comments

Comments
 (0)