mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-31 15:45:23 +00:00
feat(homepage): synchronize canvas layouts across devices (#1515)
This commit is contained in:
1 parent
fdb2f74259
commit
7d06686f62
4 files changed
+145
-4
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { mapLayoutItemIds } from "./layout-item-ids.js";
|
||||
import type { Router } from "express";
|
||||
import type { PluginContext } from "@termix/plugin-sdk/backend";
|
||||
import {
|
||||
@@ -45,6 +46,27 @@ export async function activate(ctx: PluginContext) {
|
||||
order: 70,
|
||||
});
|
||||
|
||||
ctx.sync.registerEntity({
|
||||
type: "homepageLayouts",
|
||||
table: layouts,
|
||||
order: 81,
|
||||
singleton: true,
|
||||
serialize: async (row, resolveSyncId) => ({
|
||||
...row,
|
||||
layout: await mapLayoutItemIds(row.layout as string, async (id) =>
|
||||
typeof id === "number" && Number.isInteger(id)
|
||||
? resolveSyncId("homepageItems", id)
|
||||
: null,
|
||||
),
|
||||
}),
|
||||
deserialize: async (row, resolveId) => ({
|
||||
...row,
|
||||
layout: await mapLayoutItemIds(row.layout as string, async (id) =>
|
||||
typeof id === "string" ? resolveId("homepageItems", id) : null,
|
||||
),
|
||||
}),
|
||||
});
|
||||
|
||||
ctx.services.provide("homepage.items", createHomepageItemsService(ctx, repo));
|
||||
|
||||
ctx.log.info("Homepage routes mounted at /plugin-api/homepage");
|
||||
|
||||
Reference in new issue
Block a user