Skip to content

Commit add4296

Browse files
committed
used realtime
1 parent 37c38c7 commit add4296

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

  • src
    • lib/helpers
    • routes/(console)/project-[region]-[project]/functions/function-[function]/deployment-[deployment]

src/lib/helpers/buildTimeout.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import type { Models } from '@appwrite.io/console';
33
/**
44
* Checks if a build has exceeded the maximum build timeout duration
55
*/
6-
export function isBuildTimedOut(
7-
createdAt: string,
8-
status: string,
9-
timeoutSeconds: number
10-
): boolean {
6+
function isBuildTimedOut(createdAt: string, status: string, timeoutSeconds: number): boolean {
117
if (!['waiting', 'processing', 'building'].includes(status)) {
128
return false;
139
}

src/routes/(console)/project-[region]-[project]/functions/function-[function]/deployment-[deployment]/+page.svelte

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { Button } from '$lib/elements/forms';
33
import { Container } from '$lib/layout';
4-
import { sdk } from '$lib/stores/sdk';
4+
import { realtime } from '$lib/stores/sdk';
55
import { onMount } from 'svelte';
66
import { type Models } from '@appwrite.io/console';
77
import { page } from '$app/state';
@@ -53,21 +53,18 @@
5353
let showRedeploy = $state(false);
5454
5555
onMount(() => {
56-
const unsubscribe = sdk.forConsole.client.subscribe<Models.Deployment>(
57-
'console',
58-
(message) => {
59-
if (
60-
message.events.includes(
61-
`functions.${page.params.function}.deployments.${page.params.deployment}.update`
62-
)
63-
) {
64-
if (['ready', 'failed'].includes(message.payload.status)) {
65-
invalidate(Dependencies.DEPLOYMENT);
66-
}
56+
return realtime.forConsole(page.params.region, 'console', (message) => {
57+
if (
58+
message.events.includes(
59+
`functions.${page.params.function}.deployments.${page.params.deployment}.update`
60+
)
61+
) {
62+
const payload = message.payload as Models.Deployment;
63+
if (['ready', 'failed'].includes(payload.status)) {
64+
invalidate(Dependencies.DEPLOYMENT);
6765
}
6866
}
69-
);
70-
return unsubscribe;
67+
});
7168
});
7269
7370
export function badgeTypeDeployment(status: string) {

0 commit comments

Comments
 (0)