mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
web: fix release track switching
This commit is contained in:
3
apps/web/.gitignore
vendored
3
apps/web/.gitignore
vendored
@@ -30,4 +30,5 @@ dist
|
||||
public/workbox
|
||||
scripts/secrets
|
||||
test-results
|
||||
.swc
|
||||
.swc
|
||||
.wrangler
|
||||
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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")}`;
|
||||
|
||||
Reference in New Issue
Block a user