fix
This commit is contained in:
parent
964f0fe8ba
commit
c64fe0e4d0
File diff suppressed because one or more lines are too long
|
|
@ -176,6 +176,7 @@ 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,
|
||||||
|
|
|
||||||
|
|
@ -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