mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: start work on realtime
This commit is contained in:
1 parent
8bfeac4f2d
commit
36b6fbb50a
3 files changed
+29
-3
No files matched your search
@@ -1,10 +1,25 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { updateLayout } from '$lib/stores/layout';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { deploymentList } from './function/[function]/store';
|
||||
|
||||
let loaded = false;
|
||||
|
||||
if (browser) {
|
||||
sdkForConsole.client.subscribe<Models.Deployment>('console', (message) => {
|
||||
console.log(message);
|
||||
|
||||
if (message.events.includes('functions.*.deployments.*.update')) {
|
||||
deploymentList.updateDeployment(<Models.Deployment>message.payload);
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
onMount(handle);
|
||||
afterNavigate(handle);
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@ export const deploymentList = cachedStore<
|
||||
Models.DeploymentList,
|
||||
{
|
||||
load: (functionId: string, search: string, limit: number, offset: number) => Promise<void>;
|
||||
updateDeployment: (deployment: Models.Deployment) => void;
|
||||
}
|
||||
>('deploymentList', function ({ set }) {
|
||||
>('deploymentList', function ({ set, update }) {
|
||||
return {
|
||||
load: async (functionId, search, limit, offset) => {
|
||||
const response = await sdkForProject.functions.listDeployments(
|
||||
@@ -30,6 +31,15 @@ export const deploymentList = cachedStore<
|
||||
offset
|
||||
);
|
||||
set(response);
|
||||
}
|
||||
},
|
||||
updateDeployment: (deployment) =>
|
||||
update((n) => {
|
||||
const index = n.deployments.findIndex((a) => a.$id === deployment.$id);
|
||||
if (index !== -1) {
|
||||
n.deployments[index] = deployment;
|
||||
}
|
||||
|
||||
return n;
|
||||
})
|
||||
};
|
||||
});
|
||||
@@ -14,6 +14,7 @@ export const functionList = cachedStore<
|
||||
const response = await sdkForProject.functions.list(search, limit, offset);
|
||||
set(response);
|
||||
},
|
||||
|
||||
getDeployment: async (functionId, deploymentId) => {
|
||||
return await sdkForProject.functions.getDeployment(functionId, deploymentId);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user