|
29 | 29 | import { Container } from '$lib/layout'; |
30 | 30 | import { app } from '$lib/stores/app'; |
31 | 31 | import { calculateSize, humanFileSize } from '$lib/helpers/sizeConvertion'; |
32 | | - import { Query, type Models } from '@appwrite.io/console'; |
| 32 | + import type { Models } from '@appwrite.io/console'; |
33 | 33 | import Delete from './delete.svelte'; |
34 | 34 | import Create from './create.svelte'; |
35 | | - import { sdk } from '$lib/stores/sdk'; |
36 | 35 | import Activate from './activate.svelte'; |
37 | 36 | import { calculateTime } from '$lib/helpers/timeConversion'; |
38 | 37 | import { Pill } from '$lib/elements'; |
|
50 | 49 | let showAlert = true; |
51 | 50 |
|
52 | 51 | let selectedDeployment: Models.Deployment = null; |
53 | | - let activeDeployment: Models.Deployment = null; |
54 | | -
|
55 | | - async function getActiveDeployment() { |
56 | | - if (!$func?.deployment) return null; |
57 | | - const list = await sdk.forProject.functions.listDeployments($page.params.function, [ |
58 | | - Query.equal('$id', $func.deployment) |
59 | | - ]); |
60 | | - return list?.deployments?.[0]; |
61 | | - } |
62 | 52 |
|
63 | 53 | function handleActivate() { |
64 | 54 | invalidate(Dependencies.DEPLOYMENTS); |
65 | 55 | } |
66 | | -
|
67 | | - deploymentList.subscribe((list: Models.DeploymentList | null) => { |
68 | | - if (list?.deployments) { |
69 | | - let activeDep = list.deployments.find( |
70 | | - (deployment) => deployment.$id === $func.deployment |
71 | | - ); |
72 | | - if (!activeDep) { |
73 | | - getActiveDeployment().then((deployment) => { |
74 | | - activeDeployment = deployment; |
75 | | - }); |
76 | | - } else { |
77 | | - activeDeployment = activeDep; |
78 | | - } |
79 | | - } |
80 | | - }); |
81 | 56 | </script> |
82 | 57 |
|
83 | 58 | <Container> |
|
86 | 61 | <Create main /> |
87 | 62 | </div> |
88 | 63 | {#if $deploymentList?.total} |
| 64 | + {@const activeDeployment = data.activeDeployment} |
89 | 65 | <div class="common-section"> |
90 | 66 | <Heading tag="h3" size="7">Active</Heading> |
91 | 67 | </div> |
|
113 | 89 | <div class="u-grid-equal-row-size u-gap-4 u-line-height-1"> |
114 | 90 | <p><b>Deployment ID</b></p> |
115 | 91 |
|
116 | | - <Id value={$func.deployment}> |
117 | | - {$func.deployment} |
| 92 | + <Id value={activeDeployment.$id}> |
| 93 | + {activeDeployment.$id} |
118 | 94 | </Id> |
119 | 95 | </div> |
120 | 96 | </div> |
|
197 | 173 | </div> |
198 | 174 | </Empty> |
199 | 175 | {/if} |
200 | | - |
201 | 176 | <div class="common-section"> |
202 | 177 | <Heading tag="h3" size="7">All</Heading> |
203 | 178 | </div> |
|
0 commit comments