From 748bd69553abd6401dca10677732deb6882d874c Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Thu, 12 Sep 2024 15:54:48 +0530 Subject: [PATCH] improve: avoid backup checks on free plan. --- src/lib/components/backupRestoreBox.svelte | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/components/backupRestoreBox.svelte b/src/lib/components/backupRestoreBox.svelte index 139b1461e..0f33488c5 100644 --- a/src/lib/components/backupRestoreBox.svelte +++ b/src/lib/components/backupRestoreBox.svelte @@ -2,6 +2,9 @@ import { sdk } from '$lib/stores/sdk'; import { type Models, Query } from '@appwrite.io/console'; import { onMount } from 'svelte'; + import { isCloud } from '$lib/system'; + import { organization } from '$lib/stores/organization'; + import { BillingPlan } from '$lib/constants'; let backupRestoreItems: { archives: Models.BackupArchive[]; @@ -15,6 +18,9 @@ backupRestoreItems.archives.length > 0 || backupRestoreItems.restorations.length > 0; const fetchBackupRestores = async (fromRealtime: boolean = false) => { + // fast path: don't fetch if org is on a free plan. + if (isCloud && $organization.billingPlan === BillingPlan.FREE) return; + try { const query = [Query.orderDesc('')]; @@ -66,6 +72,9 @@ }; onMount(() => { + // fast path: don't subscribe if org is on a free plan. + if (isCloud && $organization.billingPlan === BillingPlan.FREE) return; + sdk.forConsole.client.subscribe('console', (response) => { if ( response.events.includes('archives.*') ||