mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 15:00:30 +03:00
Swap to sending to service worker for completion
This commit is contained in:
parent
07e15e2421
commit
0c67cb40d7
1 changed files with 15 additions and 3 deletions
|
|
@ -86,7 +86,13 @@ export async function enablePushNotifications(
|
|||
};
|
||||
|
||||
try {
|
||||
await mx.setPusher(pusherData);
|
||||
|
||||
navigator.serviceWorker.controller?.postMessage({
|
||||
url: mx.baseUrl,
|
||||
type: 'togglePush',
|
||||
pusherData,
|
||||
token: mx.getAccessToken(),
|
||||
});
|
||||
} catch (pusherError: any) {
|
||||
await subscription.unsubscribe();
|
||||
throw new Error(
|
||||
|
|
@ -119,12 +125,18 @@ export async function disablePushNotifications(
|
|||
const authKey = subJson.keys?.auth;
|
||||
|
||||
if (mx && mx.getAccessToken() && pwaAppIdForPlatform) {
|
||||
const pusherToRemove = {
|
||||
const pusherData = {
|
||||
kind: null,
|
||||
app_id: pwaAppIdForPlatform,
|
||||
pushkey: p256dhKey,
|
||||
};
|
||||
await mx.setPusher(pusherToRemove as any);
|
||||
|
||||
navigator.serviceWorker.controller?.postMessage({
|
||||
url: mx.baseUrl,
|
||||
type: 'togglePush',
|
||||
pusherData,
|
||||
token: mx.getAccessToken(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue