wip fix
This commit is contained in:
parent
f222c43426
commit
a5954fb0d7
|
|
@ -1,19 +1,10 @@
|
||||||
import { EPage } from "../../../../web/src/nova/ed/logic/ed-global";
|
|
||||||
import { initLoadComp } from "../../../../web/src/nova/vi/meta/comp/init-comp-load";
|
|
||||||
import { genMeta } from "../../../../web/src/nova/vi/meta/meta";
|
|
||||||
import { simplifyMeta } from "../../../../web/src/nova/vi/meta/simplify";
|
|
||||||
import { GenMetaP, IMeta } from "../../../../web/src/nova/vi/utils/types";
|
|
||||||
import { IItem } from "../../../../web/src/utils/types/item";
|
|
||||||
import { DPage } from "../../../../web/src/utils/types/root";
|
|
||||||
import { SAction } from "../actions";
|
import { SAction } from "../actions";
|
||||||
import { loadComponent, userSyncComponent } from "../editor/load-component";
|
|
||||||
import { parseJs } from "../editor/parser/parse-js";
|
|
||||||
import { prepareComponentForPage } from "../editor/prep-comp-page";
|
import { prepareComponentForPage } from "../editor/prep-comp-page";
|
||||||
import { prepContentTree } from "../editor/prep-page";
|
import { prepContentTree } from "../editor/prep-page";
|
||||||
import { activity } from "../entity/activity";
|
import { activity } from "../entity/activity";
|
||||||
import { conns } from "../entity/conn";
|
import { conns } from "../entity/conn";
|
||||||
import { docs } from "../entity/docs";
|
import { docs } from "../entity/docs";
|
||||||
import { CompSnapshot, snapshot } from "../entity/snapshot";
|
import { snapshot } from "../entity/snapshot";
|
||||||
import { user } from "../entity/user";
|
import { user } from "../entity/user";
|
||||||
import { gzipAsync } from "../entity/zlib";
|
import { gzipAsync } from "../entity/zlib";
|
||||||
import { sendWS } from "../sync-handler";
|
import { sendWS } from "../sync-handler";
|
||||||
|
|
@ -123,7 +114,7 @@ export const page_load: SAction["page"]["load"] = async function (
|
||||||
url: page.url,
|
url: page.url,
|
||||||
name: page.name,
|
name: page.name,
|
||||||
snapshot: await gzipAsync(bin),
|
snapshot: await gzipAsync(bin),
|
||||||
comps: await prepareComponentForPage(id, this),
|
comps: await prepareComponentForPage(id, this, false),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if (snap && !ydoc) {
|
} else if (snap && !ydoc) {
|
||||||
|
|
@ -134,6 +125,8 @@ export const page_load: SAction["page"]["load"] = async function (
|
||||||
Y.applyUpdate(doc, snap.bin);
|
Y.applyUpdate(doc, snap.bin);
|
||||||
let root = doc.getMap("map");
|
let root = doc.getMap("map");
|
||||||
|
|
||||||
|
const comps = await prepareComponentForPage(id, this, true, doc as any);
|
||||||
|
|
||||||
const um = await createUndoManager(root);
|
const um = await createUndoManager(root);
|
||||||
await attachOnUpdate(doc, um);
|
await attachOnUpdate(doc, um);
|
||||||
|
|
||||||
|
|
@ -156,7 +149,7 @@ export const page_load: SAction["page"]["load"] = async function (
|
||||||
url: snap.url,
|
url: snap.url,
|
||||||
name: snap.name,
|
name: snap.name,
|
||||||
snapshot: await gzipAsync(snap.bin),
|
snapshot: await gzipAsync(snap.bin),
|
||||||
comps: await prepareComponentForPage(id, this),
|
comps,
|
||||||
};
|
};
|
||||||
} else if (snap && ydoc) {
|
} else if (snap && ydoc) {
|
||||||
await setActivityPage(snap.id_site, id);
|
await setActivityPage(snap.id_site, id);
|
||||||
|
|
@ -174,7 +167,7 @@ export const page_load: SAction["page"]["load"] = async function (
|
||||||
url: snap.url,
|
url: snap.url,
|
||||||
name: snap.name,
|
name: snap.name,
|
||||||
snapshot: await gzipAsync(snap.bin),
|
snapshot: await gzipAsync(snap.bin),
|
||||||
comps: await prepareComponentForPage(id, this),
|
comps: await prepareComponentForPage(id, this, true),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,30 @@
|
||||||
import { EComp } from "../../../../web/src/nova/ed/logic/ed-global";
|
import { EComp } from "../../../../web/src/nova/ed/logic/ed-global";
|
||||||
import { IRoot } from "../../../../web/src/utils/types/root";
|
import { DPage, IRoot } from "../../../../web/src/utils/types/root";
|
||||||
import { docs } from "../entity/docs";
|
import { docs } from "../entity/docs";
|
||||||
import { snapshot } from "../entity/snapshot";
|
import { snapshot } from "../entity/snapshot";
|
||||||
import { gzipAsync } from "../entity/zlib";
|
import { gzipAsync } from "../entity/zlib";
|
||||||
import { SyncConnection } from "../type";
|
import { SyncConnection } from "../type";
|
||||||
import { loadComponent } from "./load-component";
|
import { loadComponent } from "./load-component";
|
||||||
|
import { loadCompForPage } from "./prep-page";
|
||||||
|
|
||||||
export const prepareComponentForPage = async (
|
export const prepareComponentForPage = async (
|
||||||
page_id: string,
|
page_id: string,
|
||||||
sync: SyncConnection
|
sync: SyncConnection,
|
||||||
|
reload_components: boolean,
|
||||||
|
doc?: DPage
|
||||||
) => {
|
) => {
|
||||||
const doc = docs.page[page_id].doc;
|
const _doc = doc ? doc : docs.page[page_id].doc;
|
||||||
const root = doc.getMap("map").get("root")?.toJSON() as IRoot;
|
const root = _doc.getMap("map").get("root")?.toJSON() as IRoot;
|
||||||
|
|
||||||
const result = {} as Record<string, EComp>;
|
const result = {} as Record<string, EComp>;
|
||||||
|
|
||||||
|
if (reload_components) {
|
||||||
|
root.component_ids = await loadCompForPage(root, sync);
|
||||||
|
if (doc) {
|
||||||
|
_doc.getMap("map").get("root")?.set("component_ids", root.component_ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (root.component_ids) {
|
if (root.component_ids) {
|
||||||
for (const id of root.component_ids) {
|
for (const id of root.component_ids) {
|
||||||
if (!docs.comp[id]) {
|
if (!docs.comp[id]) {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export const prepContentTree = async (
|
||||||
return root;
|
return root;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadCompForPage = async (ctree: IRoot, sync: SyncConnection) => {
|
export const loadCompForPage = async (ctree: IRoot, sync: SyncConnection) => {
|
||||||
const meta: GenMetaP["meta"] = {};
|
const meta: GenMetaP["meta"] = {};
|
||||||
const mcomps: GenMetaP["comps"] = {};
|
const mcomps: GenMetaP["comps"] = {};
|
||||||
const result = new Set<string>();
|
const result = new Set<string>();
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,13 @@ export type IRoot = {
|
||||||
id_page?: string;
|
id_page?: string;
|
||||||
childs: ISection[];
|
childs: ISection[];
|
||||||
component_ids?: string[];
|
component_ids?: string[];
|
||||||
entry_ids?: string[];
|
|
||||||
};
|
};
|
||||||
export type MRoot = TypedMap<{
|
export type MRoot = TypedMap<{
|
||||||
id: "root";
|
id: "root";
|
||||||
|
id_page?: string;
|
||||||
type: "root";
|
type: "root";
|
||||||
childs: TypedArray<ISection>;
|
childs: TypedArray<ISection>;
|
||||||
|
component_ids?: string[];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export type DPage = TypedDoc<{
|
export type DPage = TypedDoc<{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue