This commit is contained in:
Rizky 2024-07-02 15:00:30 +07:00
parent dfd36914c5
commit 188f1905f8
6 changed files with 20 additions and 5 deletions

View File

@ -166,7 +166,9 @@ export const _ = {
}
);
} catch (e) {
return new Response("");
return new Response("location.reload", {
headers: { "content-type": "application/javascript" },
});
}
}
case "route": {

View File

@ -1,3 +1,4 @@
import { g } from "utils/global";
import { SAction } from "../actions";
import { prepareComponentForPage } from "../editor/prep-comp-page";
import { prepContentTree } from "../editor/prep-page";
@ -37,9 +38,13 @@ export const page_load: SAction["page"]["load"] = async function (
doc.on("update", async (update: Uint8Array, origin: any) => {
const bin = Y.encodeStateAsUpdate(doc);
snapshot.set("page", id, "bin", bin);
snap = snapshot.get("page", id);
const sv_local = await gzipAsync(update);
if (snap?.name.startsWith("layout:") && snap.id_site && g.route_cache) {
delete g.route_cache[snap.id_site];
}
const client_ids = new Set<string>();
user.active.findAll({ page_id: id }).forEach((e) => {
client_ids.add(e.client_id);

View File

@ -11,7 +11,7 @@ export const yjs_sv_local: SAction["yjs"]["sv_local"] = async function (
) {
if (!docs[mode][id]) {
console.log(`sv_local not found`, mode, id);
return;
return { diff: "not-found", sv: "not-found" } as any;
}
const doc = docs[mode][id].doc as Y.Doc;

View File

@ -84,6 +84,9 @@ export const loadCompSnapshot = async (
);
if (res) {
if (res.sv === res.diff && (res.sv as any) === "not-found")
location.reload();
const diff_local = Y.encodeStateAsUpdate(
doc as any,
decompress(res.sv)

View File

@ -80,6 +80,9 @@ export const reloadLayout = async (p: PG, layout_id: string, note: string) => {
);
if (res) {
if (res.sv === res.diff && (res.sv as any) === "not-found")
location.reload();
const diff_local = Y.encodeStateAsUpdate(
doc as any,
decompress(res.sv)
@ -195,6 +198,9 @@ export const reloadPage = async (
);
if (res) {
if (res.sv === res.diff && (res.sv as any) === "not-found")
location.reload();
const diff_local = Y.encodeStateAsUpdate(
doc as any,
decompress(res.sv)

View File

@ -13,8 +13,7 @@ export const ResponsiveToggle = () => {
const render = () => {
const code = p.code["site"]?.doc;
if (code) {
const src = code.getMap("map").get("files")?.get("index.js");
applyEnv(p, src);
applyEnv(p);
}
treeRebuild(p);