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.

fix: Sometimes publishing status indicator doesn't correspond actual publishing (#3973)

Ivan Starkov86a5512c7770
diff --git a/packages/project/src/db/project.ts b/packages/project/src/db/project.ts
index da70b4d7a5..ce30111cdd 100644
--- a/packages/project/src/db/project.ts
+++ b/packages/project/src/db/project.ts
@@ -28,7 +28,7 @@ export const loadById = async (
`
*,
previewImageAsset:Asset (*),
- latestBuild:LatestBuildPerProject (*),
+ latestBuilds:LatestBuildPerProject (*),
latestStaticBuild:LatestStaticBuildPerProject (*)
`
)
@@ -38,15 +38,23 @@ export const loadById = async (
if (data.error) {
throw data.error;
}
- const { latestBuild, latestStaticBuild, ...project } = data.data;
+ const { latestBuilds, latestStaticBuild, ...project } = data.data;
+
+ // latestBuilds is an array containing the latest builds for each project domain (which can be renamed).
+ // We need to find the latest build for the current project domain.
+ // postgres marks all view fields as nullable
+ // workaround this by casting to non nullable
+ const latestBuild = (latestBuilds.filter(
+ (build) => build.domain === project.domain
+ )?.[0] ?? null) as null | SetNonNullable<
+ NonNullable<(typeof latestBuilds)[number]>
+ >;
return {
...project,
+ latestBuild,
// postgres marks all view fields as nullable
// workaround this by casting to non nullable
- latestBuild: (latestBuild[0] ?? null) as null | SetNonNullable<
- NonNullable<(typeof latestBuild)[0]>
- >,
latestStaticBuild: (latestStaticBuild[0] ?? null) as null | SetNonNullable<
NonNullable<(typeof latestStaticBuild)[0]>
>,