fix
This commit is contained in:
parent
964f0fe8ba
commit
c64fe0e4d0
File diff suppressed because one or more lines are too long
|
|
@ -157,7 +157,7 @@ export const EDGlobal = {
|
||||||
script: {
|
script: {
|
||||||
site_types: {} as Record<string, string>,
|
site_types: {} as Record<string, string>,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
do_edit: async (newval: string, all?: boolean) => { },
|
do_edit: async (newval: string, all?: boolean) => {},
|
||||||
db: null as any,
|
db: null as any,
|
||||||
api: null as any,
|
api: null as any,
|
||||||
init_local_effect: {} as Record<string, boolean>,
|
init_local_effect: {} as Record<string, boolean>,
|
||||||
|
|
@ -176,13 +176,14 @@ export const EDGlobal = {
|
||||||
page: EPage;
|
page: EPage;
|
||||||
doc: DPage;
|
doc: DPage;
|
||||||
on_update?: (bin: Uint8Array, origin: any) => Promise<void>;
|
on_update?: (bin: Uint8Array, origin: any) => Promise<void>;
|
||||||
|
update_timeout: any;
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
building: false,
|
building: false,
|
||||||
meta: {} as Record<string, IMeta>,
|
meta: {} as Record<string, IMeta>,
|
||||||
entry: [] as string[],
|
entry: [] as string[],
|
||||||
tree: [] as NodeModel<IMeta>[],
|
tree: [] as NodeModel<IMeta>[],
|
||||||
render: () => { },
|
render: () => {},
|
||||||
},
|
},
|
||||||
comp: {
|
comp: {
|
||||||
doc: null as null | DComp,
|
doc: null as null | DComp,
|
||||||
|
|
@ -295,9 +296,9 @@ export const EDGlobal = {
|
||||||
type: "item" as "item" | "prop-master" | "prop-instance" | "comp-types",
|
type: "item" as "item" | "prop-master" | "prop-instance" | "comp-types",
|
||||||
prop_kind: "" as PropFieldKind,
|
prop_kind: "" as PropFieldKind,
|
||||||
prop_name: "",
|
prop_name: "",
|
||||||
on_close: () => { },
|
on_close: () => {},
|
||||||
typings: { status: "ok" as "ok" | "loading" | "error", err_msg: "" },
|
typings: { status: "ok" as "ok" | "loading" | "error", err_msg: "" },
|
||||||
wb_render: () => { },
|
wb_render: () => {},
|
||||||
},
|
},
|
||||||
site: null as null | ((site_id: string) => void | Promise<void>),
|
site: null as null | ((site_id: string) => void | Promise<void>),
|
||||||
site_form: null as null | {
|
site_form: null as null | {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { treeCacheBuild, treeRebuild } from "./tree/build";
|
||||||
import { get, set } from "idb-keyval";
|
import { get, set } from "idb-keyval";
|
||||||
import { nav } from "../../vi/render/script/extract-nav";
|
import { nav } from "../../vi/render/script/extract-nav";
|
||||||
|
|
||||||
|
const UPDATE_TIMEOUT = 200;
|
||||||
export const edRoute = async (p: PG) => {
|
export const edRoute = async (p: PG) => {
|
||||||
if (p.sync && (p.status === "ready" || p.status === "init")) {
|
if (p.sync && (p.status === "ready" || p.status === "init")) {
|
||||||
if (!p.site.domain && !p.site.name) {
|
if (!p.site.domain && !p.site.name) {
|
||||||
|
|
@ -67,6 +68,8 @@ export const reloadLayout = async (p: PG, layout_id: string, note: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
page.on_update = async (bin: Uint8Array, origin: any) => {
|
page.on_update = async (bin: Uint8Array, origin: any) => {
|
||||||
|
clearTimeout(page.update_timeout);
|
||||||
|
page.update_timeout = setTimeout(async () => {
|
||||||
if (origin === "local" || !p.sync) return;
|
if (origin === "local" || !p.sync) return;
|
||||||
|
|
||||||
const res = await p.sync.yjs.sv_local(
|
const res = await p.sync.yjs.sv_local(
|
||||||
|
|
@ -106,6 +109,7 @@ export const reloadLayout = async (p: PG, layout_id: string, note: string) => {
|
||||||
savePageMetaCache(p, meta_cache.meta);
|
savePageMetaCache(p, meta_cache.meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, UPDATE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = (doc.getMap("map").get("root") as any)?.toJSON();
|
const root = (doc.getMap("map").get("root") as any)?.toJSON();
|
||||||
|
|
@ -170,6 +174,8 @@ export const reloadPage = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
page.on_update = async (bin: Uint8Array, origin: any) => {
|
page.on_update = async (bin: Uint8Array, origin: any) => {
|
||||||
|
clearTimeout(page.update_timeout);
|
||||||
|
page.update_timeout = setTimeout(async () => {
|
||||||
if (origin === "local" || !p.sync) return;
|
if (origin === "local" || !p.sync) return;
|
||||||
|
|
||||||
if (page.page.id !== remotePage.id) {
|
if (page.page.id !== remotePage.id) {
|
||||||
|
|
@ -210,6 +216,7 @@ export const reloadPage = async (
|
||||||
|
|
||||||
if (active.should_render_main) p.render();
|
if (active.should_render_main) p.render();
|
||||||
}
|
}
|
||||||
|
}, UPDATE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
doc.on("update", page.on_update);
|
doc.on("update", page.on_update);
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ export const devItem = (
|
||||||
{ value: string; valueBuilt?: string }
|
{ value: string; valueBuilt?: string }
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
console.log("committing", pedit);
|
||||||
if (mitem) {
|
if (mitem) {
|
||||||
for (const [item_id, changes] of Object.entries(pedit)) {
|
for (const [item_id, changes] of Object.entries(pedit)) {
|
||||||
const meta = metas[item_id];
|
const meta = metas[item_id];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue