address comments.

This commit is contained in:
Darshan
2025-10-31 16:24:35 +05:30
parent 2f27386320
commit fff134e5a2
6 changed files with 37 additions and 39 deletions
+2 -14
View File
@@ -1,4 +1,4 @@
import { isDev, isMultiRegionSupported, VARS } from '$lib/system';
import { isMultiRegionSupported, VARS } from '$lib/system';
import {
Account,
Assistant,
@@ -217,7 +217,6 @@ export type RealtimeResponse = {
payload: unknown;
};
// the generic `<T>` is too strict, any is too loose!
export type AppwriteRealtimeResponseEvent = (response: RealtimeResponse) => void;
function createRealtimeSubscription(
@@ -225,21 +224,10 @@ function createRealtimeSubscription(
channels: string | string[],
callback: AppwriteRealtimeResponseEvent
): () => void {
let closed = false;
const channelsArray = Array.isArray(channels) ? channels : [channels];
const subscriptionPromise = realtimeInstance.subscribe(channelsArray, callback);
return () => {
if (closed) return;
closed = true;
subscriptionPromise
.then((sub) => sub.close())
.catch((error) => {
if (isDev) {
console.log(error.message);
}
});
subscriptionPromise.then((sub) => sub.close());
};
}
@@ -63,8 +63,10 @@ const val APPWRITE_PUBLIC_ENDPOINT = "${sdk.forProject(page.params.region, page.
message: 'Platform created.'
});
invalidate(Dependencies.PROJECT);
invalidate(Dependencies.PLATFORMS);
await Promise.all([
invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
} catch (error) {
trackError(error, Submit.PlatformCreate);
addNotification({
@@ -81,17 +83,17 @@ const val APPWRITE_PUBLIC_ENDPOINT = "${sdk.forProject(page.params.region, page.
}
onMount(() => {
const subscription = realtime.forConsole(page.params.region, 'console', (response) => {
const unsubscribe = realtime.forConsole(page.params.region, 'console', (response) => {
if (response.events.includes(`projects.${projectId}.ping`)) {
connectionSuccessful = true;
invalidate(Dependencies.ORGANIZATION);
invalidate(Dependencies.PROJECT);
subscription();
unsubscribe();
}
});
return () => {
subscription();
unsubscribe();
resetPlatformStore();
};
});
@@ -72,8 +72,10 @@ APPWRITE_PUBLIC_ENDPOINT: "${sdk.forProject(page.params.region, page.params.proj
message: 'Platform created.'
});
invalidate(Dependencies.PROJECT);
invalidate(Dependencies.PLATFORMS);
await Promise.all([
invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
} catch (error) {
trackError(error, Submit.PlatformCreate);
addNotification({
@@ -90,17 +92,17 @@ APPWRITE_PUBLIC_ENDPOINT: "${sdk.forProject(page.params.region, page.params.proj
}
onMount(() => {
const subscription = realtime.forConsole(page.params.region, 'console', (response) => {
const unsubscribe = realtime.forConsole(page.params.region, 'console', (response) => {
if (response.events.includes(`projects.${projectId}.ping`)) {
connectionSuccessful = true;
invalidate(Dependencies.ORGANIZATION);
invalidate(Dependencies.PROJECT);
subscription();
unsubscribe();
}
});
return () => {
subscription();
unsubscribe();
resetPlatformStore();
};
});
@@ -138,8 +138,10 @@
message: 'Platform created.'
});
invalidate(Dependencies.PROJECT);
invalidate(Dependencies.PLATFORMS);
await Promise.all([
invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
} catch (error) {
trackError(error, Submit.PlatformCreate);
addNotification({
@@ -156,17 +158,17 @@
}
onMount(() => {
const subscription = realtime.forConsole(page.params.region, 'console', (response) => {
const unsubscribe = realtime.forConsole(page.params.region, 'console', (response) => {
if (response.events.includes(`projects.${projectId}.ping`)) {
connectionSuccessful = true;
invalidate(Dependencies.ORGANIZATION);
invalidate(Dependencies.PROJECT);
subscription();
unsubscribe();
}
});
return () => {
subscription();
unsubscribe();
resetPlatformStore();
};
});
@@ -99,8 +99,10 @@ EXPO_PUBLIC_APPWRITE_ENDPOINT=${sdk.forProject(page.params.region, page.params.p
message: 'Platform created.'
});
invalidate(Dependencies.PROJECT);
invalidate(Dependencies.PLATFORMS);
await Promise.all([
invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
} catch (error) {
trackError(error, Submit.PlatformCreate);
addNotification({
@@ -117,17 +119,17 @@ EXPO_PUBLIC_APPWRITE_ENDPOINT=${sdk.forProject(page.params.region, page.params.p
}
onMount(() => {
const subscription = realtime.forConsole(page.params.region, 'console', (response) => {
const unsubscribe = realtime.forConsole(page.params.region, 'console', (response) => {
if (response.events.includes(`projects.${projectId}.ping`)) {
connectionSuccessful = true;
invalidate(Dependencies.ORGANIZATION);
invalidate(Dependencies.PROJECT);
subscription();
unsubscribe();
}
});
return () => {
subscription();
unsubscribe();
resetPlatformStore();
};
});
@@ -184,8 +184,10 @@ ${prefix}APPWRITE_ENDPOINT = "${sdk.forProject(page.params.region, page.params.p
message: 'Platform created.'
});
invalidate(Dependencies.PROJECT);
invalidate(Dependencies.PLATFORMS);
await Promise.all([
invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
} catch (error) {
trackError(error, Submit.PlatformCreate);
addNotification({
@@ -202,17 +204,17 @@ ${prefix}APPWRITE_ENDPOINT = "${sdk.forProject(page.params.region, page.params.p
}
onMount(() => {
const subscription = realtime.forConsole(page.params.region, 'console', (response) => {
const unsubscribe = realtime.forConsole(page.params.region, 'console', (response) => {
if (response.events.includes(`projects.${projectId}.ping`)) {
connectionSuccessful = true;
invalidate(Dependencies.ORGANIZATION);
invalidate(Dependencies.PROJECT);
subscription();
unsubscribe();
}
});
return () => {
subscription();
unsubscribe();
resetPlatformStore();
};
});