Skip to content

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.

clone breakpoints when publishing

Oleg Isonenaeabf711ca37
diff --git a/app/routes/index.tsx b/app/routes/index.tsx
index 253d971f05..84f8681996 100644
--- a/app/routes/index.tsx
+++ b/app/routes/index.tsx
@@ -33,8 +33,7 @@ export const loader: LoaderFunction = async ({
const [tree, props, breakpoints] = await Promise.all([
db.tree.loadByProject(project, "production"),
db.props.loadByTreeId(project.prodTreeId),
- // @todo copy breakpoints using prod tree id and then switch
- db.breakpoints.load(project.devTreeId),
+ db.breakpoints.load(project.prodTreeId),
]);
if (tree === null) {
throw new Error(`Tree ${project.prodTreeId} not found`);
diff --git a/app/shared/db/breakpoints.server.ts b/app/shared/db/breakpoints.server.ts
index ce44b54005..f943d7a8bf 100644
--- a/app/shared/db/breakpoints.server.ts
+++ b/app/shared/db/breakpoints.server.ts
@@ -36,6 +36,20 @@ export const create = async (
return data;
};
+export const clone = async ({
+ previousTreeId,
+ nextTreeId,
+}: {
+ previousTreeId: Tree["id"];
+ nextTreeId: Tree["id"];
+}) => {
+ const breakpoints = await load(previousTreeId);
+ if (breakpoints === null) {
+ throw new Error(`Didn't find breakpoints with tree id "${previousTreeId}"`);
+ }
+ await create(nextTreeId, breakpoints.values);
+};
+
export const patch = async (
{ treeId }: { treeId: Tree["id"]; projectId: Project["id"] },
patches: Array<Patch>
diff --git a/app/shared/db/misc.server.ts b/app/shared/db/misc.server.ts
index 97e2d59764..114bce083e 100644
--- a/app/shared/db/misc.server.ts
+++ b/app/shared/db/misc.server.ts
@@ -28,7 +28,10 @@ export const publish = async ({
previousTreeId: project.devTreeId,
nextTreeId: tree.id,
});
-
+ await db.breakpoints.clone({
+ previousTreeId: project.devTreeId,
+ nextTreeId: tree.id,
+ });
const { prodTreeIdHistory } = project;
if (project.prodTreeId) {
prodTreeIdHistory.push(project.prodTreeId);