Добавить смену профилей, но она пока не работает

This commit is contained in:
AidarKC
2026-09-03 12:37:23 +04:00
parent e7c8fd748c
commit ebc9143593
15 changed files with 672 additions and 44 deletions
+7 -8
View File
@@ -202,19 +202,13 @@ self.addEventListener('notificationclick', (event) => {
}
const allClients = await self.clients.matchAll({ type: 'window', includeUncontrolled: true });
const existing = allClients.find((client) => {
try {
return client.url.includes('/index.html') || client.url.endsWith('/');
} catch {
return false;
}
});
const existing = allClients[0] || null;
const openUrlBase = './index.html';
const encodedPayload = encodeCallPushPayloadForUrl(payload);
const openUrl = (action === 'accept' || action === 'decline')
? `${openUrlBase}?callPushAction=${encodeURIComponent(action)}&callPushPayload=${encodedPayload}`
: openUrlBase;
: `${openUrlBase}?pushOpenPayload=${encodedPayload}`;
if (existing) {
try {
@@ -224,6 +218,11 @@ self.addEventListener('notificationclick', (event) => {
action,
payload,
});
} else {
existing.postMessage({
type: 'SHINE_NOTIFICATION_CLICK',
payload,
});
}
} catch {}
await existing.focus();