diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/overview.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/overview.svelte index 4e84b78f67..0932d2d79a 100644 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/overview.svelte +++ b/packages/builder/src/pages/builder/portal/overview/[appId]/overview.svelte @@ -51,6 +51,26 @@ return groups.actions.getGroupAppIds(group).includes(prodAppId) }) + const updateDeploymentString = () => { + return deployments?.length + ? processStringSync( + "Last published {{ duration time 'millisecond' }} ago", + { + time: + new Date().getTime() - + new Date(deployments[0].updatedAt).getTime(), + } + ) + : "" + } + // App is updating in the layout asynchronously + $: if ($store.appId?.length) { + fetchDeployments().then(resp => { + deployments = resp + }) + } + $: deploymentString = updateDeploymentString(deployments) + async function fetchAppEditor(editorId) { appEditor = await users.get(editorId) } @@ -107,19 +127,11 @@
- {#if deployments?.length} - {processStringSync( - "Last published {{ duration time 'millisecond' }} ago", - { - time: - new Date().getTime() - - new Date(deployments[0].updatedAt).getTime(), - } - )} - {#if isPublished} - - Unpublish - {/if} + {#if isPublished} + {deploymentString} + - Unpublish {/if} + {#if !deployments?.length} - {/if} diff --git a/packages/server/src/api/controllers/deploy/index.ts b/packages/server/src/api/controllers/deploy/index.ts index 60239d2c4c..6a31998c14 100644 --- a/packages/server/src/api/controllers/deploy/index.ts +++ b/packages/server/src/api/controllers/deploy/index.ts @@ -104,6 +104,7 @@ export async function fetchDeployments(ctx: any) { } ctx.body = Object.values(deployments.history).reverse() } catch (err) { + console.error(err) ctx.body = [] } }