fix prep-page
This commit is contained in:
parent
1748c55641
commit
207281726a
|
|
@ -51,53 +51,55 @@ export const loadCompForPage = async (ctree: IRoot, sync: SyncConnection) => {
|
||||||
const result = new Set<string>();
|
const result = new Set<string>();
|
||||||
const loading = {} as Record<string, Promise<void>>;
|
const loading = {} as Record<string, Promise<void>>;
|
||||||
const should_save = {} as Record<string, IItem>;
|
const should_save = {} as Record<string, IItem>;
|
||||||
for (const child of ctree.childs) {
|
if (ctree && ctree.childs) {
|
||||||
await initLoadComp(
|
for (const child of ctree.childs) {
|
||||||
{ comps: mcomps, meta, mode: "page" },
|
await initLoadComp(
|
||||||
child as unknown as IItem,
|
{ comps: mcomps, meta, mode: "page" },
|
||||||
{
|
child as unknown as IItem,
|
||||||
visit(meta, item, shared) {
|
{
|
||||||
if (item.adv?.js) {
|
visit(meta, item, shared) {
|
||||||
let script = undefined;
|
if (item.adv?.js) {
|
||||||
script = parseJs(item.adv.js);
|
let script = undefined;
|
||||||
if (
|
script = parseJs(item.adv.js);
|
||||||
!item.script ||
|
if (
|
||||||
Object.keys(script || {}).length !==
|
!item.script ||
|
||||||
Object.keys(item.script || {}).length
|
Object.keys(script || {}).length !==
|
||||||
) {
|
Object.keys(item.script || {}).length
|
||||||
shared.should_save = true;
|
) {
|
||||||
item.script = script;
|
shared.should_save = true;
|
||||||
}
|
item.script = script;
|
||||||
}
|
|
||||||
},
|
|
||||||
async done(shared) {
|
|
||||||
if (shared.should_save && shared.root.component?.id) {
|
|
||||||
should_save[shared.root.component.id] = shared.root;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
load: async (comp_ids) => {
|
|
||||||
for (const id of comp_ids) {
|
|
||||||
if (!docs.comp[id]) {
|
|
||||||
if (typeof loading[id] === "undefined") {
|
|
||||||
loading[id] = new Promise<void>(async (resolve) => {
|
|
||||||
await loadComponent(id, sync);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
await loading[id];
|
|
||||||
} else {
|
|
||||||
userSyncComponent(sync, id);
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
async done(shared) {
|
||||||
|
if (shared.should_save && shared.root.component?.id) {
|
||||||
|
should_save[shared.root.component.id] = shared.root;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
load: async (comp_ids) => {
|
||||||
|
for (const id of comp_ids) {
|
||||||
|
if (!docs.comp[id]) {
|
||||||
|
if (typeof loading[id] === "undefined") {
|
||||||
|
loading[id] = new Promise<void>(async (resolve) => {
|
||||||
|
await loadComponent(id, sync);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await loading[id];
|
||||||
|
} else {
|
||||||
|
userSyncComponent(sync, id);
|
||||||
|
}
|
||||||
|
|
||||||
result.add(id);
|
result.add(id);
|
||||||
mcomps[id] = docs.comp[id].doc
|
mcomps[id] = docs.comp[id].doc
|
||||||
.getMap("map")
|
.getMap("map")
|
||||||
.get("root")
|
.get("root")
|
||||||
?.toJSON() as IItem;
|
?.toJSON() as IItem;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(should_save).length > 0) {
|
if (Object.keys(should_save).length > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue