Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: cloud active deployment not visible #487

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@
import { log } from '$lib/stores/logs';
import { invalidate } from '$app/navigation';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { Models } from '@aw-labs/appwrite-console';
import { Query, type Models } from '@aw-labs/appwrite-console';
import type { PageData } from './$types';
import Delete from '../delete.svelte';
import Create from '../create.svelte';
import Activate from '../activate.svelte';
import { browser } from '$app/environment';
import { sdkForConsole } from '$lib/stores/sdk';
import { sdkForConsole, sdkForProject } from '$lib/stores/sdk';
import { page } from '$app/stores';
import Output from '$lib/components/output.svelte';
import { calculateTime } from '$lib/helpers/timeConversion';
import { timer } from '$lib/actions/timer';
import { onMount } from 'svelte';

export let data: PageData;

Expand All @@ -49,13 +50,23 @@
let showActivate = false;

let selectedDeployment: Models.Deployment = null;
let activeDeployment: Models.Deployment = null;

onMount(async () => {
activeDeployment = await getActiveDeployment();
});

async function getActiveDeployment() {
const list = await sdkForProject.functions.listDeployments($page.params.function, [
Query.equal('$id', $func?.deployment)
]);
return list?.deployments?.[0];
}

const handleActivate = () => {
invalidate(Dependencies.DEPLOYMENTS);
};

$: activeDeployment = data.deployments.deployments.find((d) => d.$id === $func?.deployment);

if (browser) {
sdkForConsole.client.subscribe<Models.Deployment>('console', (message) => {
if (message.events.includes('functions.*.deployments.*.create')) {
Expand Down