diff --git a/apps/web/src/common/index.ts b/apps/web/src/common/index.ts index 97e86428c..b8d570d59 100644 --- a/apps/web/src/common/index.ts +++ b/apps/web/src/common/index.ts @@ -37,7 +37,6 @@ import { EVENTS } from "@notesnook/core/dist/common"; import { getFormattedDate } from "@notesnook/common"; import { createWritableStream } from "./desktop-bridge"; import { ZipStream } from "../utils/streams/zip-stream"; -import { register } from "../utils/stream-saver/mitm"; import { FeatureKeys } from "../dialogs/feature-dialog"; import { Reader } from "../utils/zip-reader"; @@ -79,7 +78,6 @@ export async function introduceFeatures() { export const DEFAULT_CONTEXT = { colors: [], tags: [], notebook: {} }; export async function createBackup() { - await register(); const encryptBackups = userstore.get().isLoggedIn && Config.get("encryptBackups", false); diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsx index aaffb1bd4..9e8e9d0ab 100644 --- a/apps/web/src/index.tsx +++ b/apps/web/src/index.tsx @@ -23,6 +23,7 @@ import { logger } from "./utils/logger"; import { loadDatabase } from "./hooks/use-database"; import { AppEventManager, AppEvents } from "./common/app-events"; import { BaseThemeProvider } from "./components/theme-provider"; +import { register } from "./utils/stream-saver/mitm"; renderApp(); @@ -50,6 +51,8 @@ async function renderApp() { const serviceWorkerWhitelist: Routes[] = ["default"]; async function initializeServiceWorker() { if (!IS_DESKTOP_APP) { + await register(); + logger.info("Initializing service worker..."); const serviceWorker = await import("./service-worker-registration"); diff --git a/apps/web/src/stores/attachment-store.js b/apps/web/src/stores/attachment-store.js index 5c638367f..14fb9925b 100644 --- a/apps/web/src/stores/attachment-store.js +++ b/apps/web/src/stores/attachment-store.js @@ -23,7 +23,6 @@ import BaseStore from "./index"; import { store as editorStore } from "./editor-store"; import { checkAttachment } from "../common/attachments"; import { showToast } from "../utils/toast"; -import { register } from "../utils/stream-saver/mitm"; import { AttachmentStream } from "../utils/streams/attachment-stream"; import { ZipStream } from "../utils/streams/zip-stream"; import { createWriteStream } from "../utils/stream-saver"; @@ -57,7 +56,6 @@ class AttachmentStore extends BaseStore { (state) => (state.status = { current: 0, total: attachments.length }) ); - await register(); abortController = new AbortController(); const attachmentStream = new AttachmentStream( attachments, diff --git a/apps/web/src/utils/stream-saver/mitm.ts b/apps/web/src/utils/stream-saver/mitm.ts index 44c609213..a869d6b65 100644 --- a/apps/web/src/utils/stream-saver/mitm.ts +++ b/apps/web/src/utils/stream-saver/mitm.ts @@ -46,6 +46,7 @@ function registerWorker() { ); }) .then((swReg) => { + console.log("Stream saver service worker registered!"); const swRegTmp = swReg.installing || swReg.waiting; scope = swReg.scope;