diff --git a/app/srv/ws/sync/actions.ts b/app/srv/ws/sync/actions.ts index 1043e2aa..fc30b2d4 100644 --- a/app/srv/ws/sync/actions.ts +++ b/app/srv/ws/sync/actions.ts @@ -121,11 +121,13 @@ export const SyncActions = { } ) => ({}) as boolean | ParsedScope | string, action: async ( - arg: { site_id: string } & ( - | { type: "startup-check" } - | { type: "startup-run" } - | { type: "startup-stop" } - ) + arg: + | ({ site_id: string } & ( + | { type: "startup-check" } + | { type: "startup-run" } + | { type: "startup-stop" } + )) + | { type: "flush-page-cache"; page_id: string } ) => ({}) as | undefined diff --git a/app/srv/ws/sync/actions/code_action.ts b/app/srv/ws/sync/actions/code_action.ts index e1b5d134..ed316457 100644 --- a/app/srv/ws/sync/actions/code_action.ts +++ b/app/srv/ws/sync/actions/code_action.ts @@ -4,6 +4,8 @@ import { waitUntil } from "web-utils"; import { SAction } from "../actions"; import { code } from "../editor/code/util-code"; import { SyncConnection } from "../type"; +import { snapshot } from "../entity/snapshot"; +import { docs } from "../entity/docs"; const code_startup = { process: {} as Record, @@ -55,5 +57,14 @@ export const code_action: SAction["code"]["action"] = async function ( } break; } + case "flush-page-cache": { + const { page_id } = arg; + snapshot.del("page", page_id); + if (docs.page[page_id] && docs.page[page_id].doc) { + docs.page[page_id].doc.destroy(); + } + delete docs.page[page_id]; + break; + } } }; diff --git a/app/web/src/nova/ed/logic/ed-route.ts b/app/web/src/nova/ed/logic/ed-route.ts index 08b6ea30..b022f522 100644 --- a/app/web/src/nova/ed/logic/ed-route.ts +++ b/app/web/src/nova/ed/logic/ed-route.ts @@ -216,6 +216,14 @@ export const reloadPage = async ( .get("root") ?.get("childs") ?.map((e) => e.get("id")) as string[]; + + if (!Array.isArray(p.page.entry)) { + p.sync.code + .action({ type: "flush-page-cache", page_id: page_id }) + .then(() => { + location.reload(); + }); + } } if (p.page.doc) {