This commit is contained in:
Rizky 2024-01-27 17:18:53 +07:00
parent 5c33260913
commit 4a8960b023
2 changed files with 4 additions and 7 deletions

View File

@ -83,14 +83,14 @@ export const code_edit: SAction["code"]["edit"] = async function (
} }
}); });
if (save_to === "comp") { if (save_to === "comp" && comp_id) {
await db.component.update({ await db.component.update({
where: { id: comp_id }, where: { id: comp_id },
data: { data: {
content_tree: root.toJSON(), content_tree: root.toJSON(),
}, },
}); });
} else { } else if (page_id) {
await db.page.update({ await db.page.update({
where: { id: page_id }, where: { id: page_id },
data: { data: {
@ -120,14 +120,14 @@ export const code_edit: SAction["code"]["edit"] = async function (
mprop.set("valueBuilt", res.code.substring(6)); mprop.set("valueBuilt", res.code.substring(6));
}); });
if (save_to === "comp") { if (save_to === "comp" && comp_id) {
await db.component.update({ await db.component.update({
where: { id: comp_id }, where: { id: comp_id },
data: { data: {
content_tree: root.toJSON(), content_tree: root.toJSON(),
}, },
}); });
} else { } else if (page_id) {
await db.page.update({ await db.page.update({
where: { id: page_id }, where: { id: page_id },
data: { data: {

View File

@ -56,9 +56,6 @@ export const loadComponent = async (comp_id: string, sync?: SyncConnection) => {
const comp = await db.component.findFirst({ where: { id: comp_id } }); const comp = await db.component.findFirst({ where: { id: comp_id } });
if (comp) { if (comp) {
const item = comp.content_tree as IItem; const item = comp.content_tree as IItem;
if (item.name === "card") {
console.log(item);
}
if (item && item.component?.id !== comp.id) { if (item && item.component?.id !== comp.id) {
item.component = { id: comp.id, props: {} }; item.component = { id: comp.id, props: {} };
} }