mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
Push the updates
This commit is contained in:
@@ -74,6 +74,12 @@ export const Notifications = observer(() => {
|
|||||||
}
|
}
|
||||||
onChange={async (pushEnabled) => {
|
onChange={async (pushEnabled) => {
|
||||||
try {
|
try {
|
||||||
|
console.log(
|
||||||
|
urlBase64ToUint8Array(
|
||||||
|
client.configuration!.vapid,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
if (!("serviceWorker" in navigator)) {
|
if (!("serviceWorker" in navigator)) {
|
||||||
return modalController.push({
|
return modalController.push({
|
||||||
type: "error",
|
type: "error",
|
||||||
@@ -81,16 +87,19 @@ export const Notifications = observer(() => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let reg =
|
const regReady = await navigator.serviceWorker
|
||||||
|
.ready;
|
||||||
|
if (!regReady) {
|
||||||
|
return modalController.push({
|
||||||
|
type: "error",
|
||||||
|
error: "ServiceWorkerNotReady",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const reg =
|
||||||
await navigator.serviceWorker.getRegistration(
|
await navigator.serviceWorker.getRegistration(
|
||||||
`${window.location.origin}/sw.js`,
|
`${window.location.origin}/sw.js`,
|
||||||
);
|
);
|
||||||
if (!reg) {
|
|
||||||
reg =
|
|
||||||
await navigator.serviceWorker.register(
|
|
||||||
`${window.location.origin}/sw.js`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reg) {
|
if (reg) {
|
||||||
if (pushEnabled) {
|
if (pushEnabled) {
|
||||||
|
|||||||
Reference in New Issue
Block a user