From 003211ddd199b608600554c132cf58e41fcf3ede Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 11 Dec 2023 12:45:15 +0100 Subject: [PATCH] fix: racing conditions --- src/lib/stores/billing.ts | 7 +++++-- src/routes/console/+layout.svelte | 4 ---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index b7d9add04..6cba0323d 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -185,7 +185,10 @@ export function checkForTrialEnding(org: Organization) { } export function checkForUsageLimit(org: Organization) { - if (org?.billingLimits) return; + if (!org?.billingLimits) { + readOnly.set(false); + return; + } const { bandwidth, documents, executions, storage, users } = org.billingLimits; if ( bandwidth >= 100 || @@ -195,7 +198,7 @@ export function checkForUsageLimit(org: Organization) { users >= 100 ) { readOnly.set(true); - } + } else readOnly.set(false); } export async function checkPaymentAuthorizationRequired(org: Organization) { diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index 14afbce15..1cc9e99b7 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -292,12 +292,8 @@ } } - let currentOrg = JSON.stringify($organization?.$id); - organization.subscribe(async (org) => { if (!org) return; - if (currentOrg === org.$id) return; - currentOrg = org.$id; if (isCloud) { calculateTrialDay(org); checkForTrialEnding(org);