wip fix component
This commit is contained in:
parent
5a653bfc6a
commit
135e7f03df
|
|
@ -69,7 +69,11 @@ export const page_load: SAction["page"]["load"] = async function (
|
|||
};
|
||||
|
||||
user.active.delAll({ client_id: this.client_id });
|
||||
|
||||
const page = await db.page.findFirst({ where: { id } });
|
||||
if (page) {
|
||||
await prepContentTree(page.id, page.content_tree, this);
|
||||
}
|
||||
|
||||
if (!snap && !ydoc) {
|
||||
const page = await db.page.findFirst({ where: { id } });
|
||||
if (page) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ export const prepContentTree = async (
|
|||
}
|
||||
|
||||
const meta = {};
|
||||
let proot: any = root;
|
||||
genMeta(
|
||||
{
|
||||
comps,
|
||||
|
|
@ -69,6 +68,10 @@ export const loadCompForPage = async (ctree: IRoot, sync: SyncConnection) => {
|
|||
}
|
||||
|
||||
result.add(id);
|
||||
mcomps[id] = docs.comp[id].doc
|
||||
.getMap("map")
|
||||
.get("root")
|
||||
?.toJSON() as IItem;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export const genComp = (p: GenMetaP, arg: GenMetaArg) => {
|
|||
|
||||
if (item_comp) {
|
||||
let instances: undefined | typeof item.component.instances = undefined;
|
||||
|
||||
if (p.mode === "page") {
|
||||
if (!item.component.instances) {
|
||||
item.component.instances = {};
|
||||
|
|
@ -33,7 +34,7 @@ export const genComp = (p: GenMetaP, arg: GenMetaArg) => {
|
|||
if (!instances[item.id]) {
|
||||
instances[item.id] = {};
|
||||
instance = instances[item.id];
|
||||
}
|
||||
}
|
||||
|
||||
instantiate({
|
||||
item,
|
||||
|
|
@ -41,7 +42,6 @@ export const genComp = (p: GenMetaP, arg: GenMetaArg) => {
|
|||
ids: instance,
|
||||
});
|
||||
}
|
||||
|
||||
const meta: IMeta = {
|
||||
item: simplifyItemChild(item),
|
||||
parent: {
|
||||
|
|
@ -73,7 +73,7 @@ export const genComp = (p: GenMetaP, arg: GenMetaArg) => {
|
|||
prop.content.name = name;
|
||||
|
||||
genMeta(
|
||||
{ ...p },
|
||||
{ ...p, mode: "comp" },
|
||||
{
|
||||
item: prop.content,
|
||||
root: arg.root || prop.content,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export const initLoadComp = async (
|
|||
}
|
||||
},
|
||||
},
|
||||
set_meta: false,
|
||||
set_meta: false,
|
||||
note: "init-load-comp",
|
||||
},
|
||||
{ item, ignore_first_component: true }
|
||||
|
|
@ -40,6 +40,11 @@ export const initLoadComp = async (
|
|||
if (loaded) loaded.add(id);
|
||||
});
|
||||
|
||||
await initLoadComp(p, item, load, loaded);
|
||||
for (const id of [...loaded]) {
|
||||
const comp = p.comps[id];
|
||||
if (comp) {
|
||||
await initLoadComp(p, comp, load, loaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ export const instantiate = (arg: {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!newitem.component.instances) {
|
||||
newitem.component.instances = {};
|
||||
}
|
||||
newitem.component.instances = item.component?.instances;
|
||||
}
|
||||
|
||||
for (const key of Object.keys(item)) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { simplifyItemChild } from "./simplify";
|
|||
|
||||
export const genMeta = (p: GenMetaP, arg: GenMetaArg) => {
|
||||
const item = arg.item as IItem;
|
||||
|
||||
if (item.type === "item" && item.component?.id) {
|
||||
if (arg.ignore_first_component !== true) {
|
||||
genComp(p, arg);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ export const viEvalProps = (
|
|||
_jsx: true,
|
||||
fn: (arg: { passprop: any; meta: IMeta }) => {
|
||||
const id = prop.content?.id;
|
||||
console.log(prop);
|
||||
if (id) {
|
||||
const m = vi.meta[id];
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { FC, ReactNode, Suspense, lazy, useEffect } from "react";
|
||||
import { FC, ReactNode, Suspense, useEffect } from "react";
|
||||
import { useLocal } from "web-utils";
|
||||
import { IMeta } from "../../../ed/logic/ed-global";
|
||||
import { ErrorBox } from "../../utils/error-box";
|
||||
import { VG } from "../global";
|
||||
|
|
@ -7,9 +8,6 @@ import { viScriptArg } from "./arg";
|
|||
import { updatePropScope } from "./eval-prop";
|
||||
import { createViLocal } from "./local";
|
||||
import { createViPassProp } from "./passprop";
|
||||
import hash_sum from "hash-sum";
|
||||
import { flatten } from "safe-flat";
|
||||
import { useLocal } from "web-utils";
|
||||
|
||||
export const viEvalScript = (
|
||||
vi: {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ export const createViLocal = (
|
|||
|
||||
useEffect(() => {
|
||||
let id = meta.item.id;
|
||||
|
||||
if (meta.parent?.instance_id) {
|
||||
const parent_meta = metas[meta.parent?.instance_id];
|
||||
if (parent_meta && parent_meta.instances) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue