Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
SyncQueueEntry > SyncItem
Oleg Isonen0bfca1ecc3c6
diff --git a/app/canvas/shared/use-periodic-sync.ts b/app/canvas/shared/use-periodic-sync.tsindex 4ba67d45f2..2700e8e576 100644--- a/app/canvas/shared/use-periodic-sync.ts+++ b/app/canvas/shared/use-periodic-sync.ts@@ -1,12 +1,12 @@import useInterval from "react-use/lib/useInterval";-import { sync, SyncQueueEntry } from "~/lib/sync-engine";+import { sync, SyncItem } from "~/lib/sync-engine";import { publish } from "./pubsub";export const usePeriodicSync = () => {useInterval(() => {const entries = sync();if (entries.length === 0) return;- publish<"syncChanges", Array<SyncQueueEntry>>({+ publish<"syncChanges", Array<SyncItem>>({type: "syncChanges",payload: entries,});diff --git a/app/designer/features/sync/use-sync.ts b/app/designer/features/sync/use-sync.tsindex 65a35df2ba..802bfd6bff 100644--- a/app/designer/features/sync/use-sync.ts+++ b/app/designer/features/sync/use-sync.ts@@ -14,7 +14,7 @@ import type {import type { StyleUpdates } from "~/shared/component";import { useSubscribe } from "~/designer/features/canvas-iframe";import { enqueue } from "./queue";-import { type SyncQueueEntry } from "~/lib/sync-engine";+import { type SyncItem } from "~/lib/sync-engine";// @todo this entire queueing logic needs to be gone, it's a workaround,// because prisma can't do atomic updates yet with embeded documents@@ -90,7 +90,7 @@ export const useSync = ({ project }: { config: Config; project: Project }) => {);});- useSubscribe<"syncChanges", Array<SyncQueueEntry>>("syncChanges", (queue) => {+ useSubscribe<"syncChanges", Array<SyncItem>>("syncChanges", (queue) => {enqueue(() =>fetch(`/rest/patch/${project.devTreeId}`, {method: "post",diff --git a/app/lib/sync-engine/index.ts b/app/lib/sync-engine/index.tsindex 04438e3a12..7b33afa502 100644--- a/app/lib/sync-engine/index.ts+++ b/app/lib/sync-engine/index.ts@@ -1,3 +1,3 @@export { register, transaction } from "./store";-export { sync, type SyncQueueEntry } from "./sync-queue";+export { sync, type SyncItem } from "./sync-queue";export { undo, redo } from "./transactions-manager";diff --git a/app/lib/sync-engine/sync-queue.ts b/app/lib/sync-engine/sync-queue.tsindex e99cf04663..ef58619fbf 100644--- a/app/lib/sync-engine/sync-queue.ts+++ b/app/lib/sync-engine/sync-queue.ts@@ -1,11 +1,11 @@import { type Change } from "./transaction";-export type SyncQueueEntry = {+export type SyncItem = {transactionId: string;changes: Array<Change>;};-const queue: Array<SyncQueueEntry> = [];+const queue: Array<SyncItem> = [];const dequeue = (transactionId: string) => {const index = queue.findIndex(diff --git a/app/routes/rest/patch.$treeId.ts b/app/routes/rest/patch.$treeId.tsindex 1c20b698f3..05b4e1821a 100644--- a/app/routes/rest/patch.$treeId.ts+++ b/app/routes/rest/patch.$treeId.ts@@ -1,6 +1,6 @@import { type ActionFunction } from "remix";import * as db from "~/shared/db";-import { type SyncQueueEntry } from "~/lib/sync-engine";+import { type SyncItem } from "~/lib/sync-engine";const updaters = { root: db.tree.patchRoot };@@ -8,7 +8,7 @@ type UpdaterKey = keyof typeof updaters;export const action: ActionFunction = async ({ request, params }) => {if (params.treeId === undefined) return { errors: "Tree id required" };- const transactions: Array<SyncQueueEntry> = await request.json();+ const transactions: Array<SyncItem> = await request.json();// @todo parallelize the updates// currently not possible because we fetch the entire tree// and parallelized updates will cause unpredictable side effects