The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: fetch project subscription tier lazily
phamhieueced0a1b6803
diff --git a/studio/stores/app/ProjectStore.ts b/studio/stores/app/ProjectStore.tsindex bd0a9af0f1d..f417f242342 100644--- a/studio/stores/app/ProjectStore.ts+++ b/studio/stores/app/ProjectStore.ts@@ -1,3 +1,4 @@+import { cloneDeep } from 'lodash'import { Project } from 'types'import { IRootStore } from '../RootStore'import { constructHeaders } from 'lib/api/apiHelpers'@@ -40,6 +41,26 @@ export default class ProjectStore extends PostgresMetaInterface<Project> {project.postgrestStatus = success ? 'ONLINE' : 'OFFLINE'}this.data[project.id] = project++ // lazily fetch+ this.fetchSubscriptionTier(project.id, project.ref)+ }+ }++ async fetchSubscriptionTier(projectId: number, projectRef: string) {+ const url = `${this.url}/${projectRef}/subscription`+ const headers = constructHeaders(this.headers)+ const response = await get(url, { headers })+ if (!response.error) {+ const subscriptionInfo = response as {+ tier: {+ key: string+ }+ }+ // update subscription_tier key+ const clone = cloneDeep(this.data[projectId])+ clone.subscription_tier = subscriptionInfo.tier.key+ this.data[projectId] = clone}}}