@@ -13,16 +13,15 @@ import { setAppIsReady } from "./atoms/app"
|
||||
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT, isWebBuild } from "./constants"
|
||||
import { initializeApp } from "./initialize"
|
||||
import { registerAppGlobalShortcuts } from "./initialize/global-shortcuts"
|
||||
import { registerWebPushNotifications } from "./push-notification"
|
||||
import { router } from "./router"
|
||||
|
||||
initializeApp().finally(() => {
|
||||
import("./push-notification").then(({ registerWebPushNotifications }) => {
|
||||
registerWebPushNotifications()
|
||||
if (navigator.serviceWorker && isWebBuild) {
|
||||
registerWebPushNotifications()
|
||||
}
|
||||
})
|
||||
if (navigator.serviceWorker && isWebBuild) {
|
||||
registerWebPushNotifications()
|
||||
}
|
||||
|
||||
setAppIsReady(true)
|
||||
})
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@ export async function registerWebPushNotifications() {
|
||||
const existingRegistration = await navigator.serviceWorker.getRegistration()
|
||||
let registration = existingRegistration
|
||||
|
||||
const isPWA = window.matchMedia("(display-mode: standalone)").matches
|
||||
if (!registration) {
|
||||
registration = await navigator.serviceWorker.register("/sw.js", {
|
||||
registration = await navigator.serviceWorker.register(`/sw.js${isPWA ? "?pwa=true" : ""}`, {
|
||||
scope: "/",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user