A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fix release track switching
Abdullah Atta9b6f7ff22595
diff --git a/apps/web/.gitignore b/apps/web/.gitignoreindex 828957b8c..d72e79970 100644--- a/apps/web/.gitignore+++ b/apps/web/.gitignore@@ -30,4 +30,5 @@ distpublic/workboxscripts/secretstest-results-.swc\ No newline at end of file+.swc+.wranglerdiff --git a/apps/web/public/functions/_middleware.ts b/apps/web/functions/_middleware.tssimilarity index 91%rename from apps/web/public/functions/_middleware.tsrename to apps/web/functions/_middleware.tsindex 61941ea10..cac96432a 100644--- a/apps/web/public/functions/_middleware.ts+++ b/apps/web/functions/_middleware.ts@@ -39,7 +39,11 @@ export const onRequest: PagesFunction<Env> = async ({ request, env, next }) => {betaUrl.pathname = url.pathname;betaUrl.search = url.search;console.log("Fetching asset from beta URL:", betaUrl.toString());- const asset = await fetch(betaUrl);+ const asset = await fetch(betaUrl, {+ headers: request.headers,+ method: request.method,+ body: request.body+ });return new Response(asset.body, asset);} else {return await next();diff --git a/apps/web/public/functions/tsconfig.json b/apps/web/functions/tsconfig.jsonsimilarity index 100%rename from apps/web/public/functions/tsconfig.jsonrename to apps/web/functions/tsconfig.jsondiff --git a/apps/web/src/dialogs/settings/other-settings.ts b/apps/web/src/dialogs/settings/other-settings.tsindex fc6c8f1ed..272ce785e 100644--- a/apps/web/src/dialogs/settings/other-settings.ts+++ b/apps/web/src/dialogs/settings/other-settings.ts@@ -28,6 +28,7 @@ import { useAutoUpdateStore } from "../../hooks/use-auto-updater";import { IssueDialog } from "../issue-dialog";import { strings } from "@notesnook/intl";import { desktop } from "../../common/desktop-bridge";+import { TaskManager } from "../../common/task-manager";export const AboutSettings: SettingsGroup[] = [{@@ -110,13 +111,36 @@ export const AboutSettings: SettingsGroup[] = [track: value});}- document.cookie = `release-track=${value}; Secure`;- const registrations =- (await navigator.serviceWorker?.getRegistrations()) || [];- for (const registration of registrations) {+ const registration =+ await navigator.serviceWorker.getRegistration();+ if (!registration) return;+ const worker =+ registration.active ||+ registration.waiting ||+ registration.installing;+ if (!worker) return;+ if (worker.state === "activated") {await registration.unregister();+ document.cookie = `release-track=${value}; Secure; Path=/`;+ window.location.reload();+ } else {+ await TaskManager.startTask({+ type: "modal",+ title: "Changing release track",+ subtitle:+ "Please wait while we switch to the new release track...",+ action: () =>+ new Promise<void>((resolve) => {+ worker.onstatechange = function () {+ if (this.state === "activated") {+ document.cookie = `release-track=${value}; Secure; Path=/`;+ resolve();+ window.location.reload();+ }+ };+ })+ });}- window.location.reload();}}]diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.tsindex e01fa8815..4ba4f3044 100644--- a/apps/web/vite.config.ts+++ b/apps/web/vite.config.ts@@ -64,7 +64,8 @@ export default defineConfig({manualChunks: (id: string) => {if ((id.includes("/editor/languages/") ||- id.includes("/html/languages/")) &&+ id.includes("/html/languages/") ||+ id.includes("/refractor/lang/")) &&path.basename(id) !== "index.js")return `code-lang-${path.basename(id, "js")}`;