Line data Source code
1 : import { onScopeDispose } from 'vue'
2 :
3 : import { refreshBillingAccount } from '@/platform/billing/billingAccountRefresh'
4 : import { useBillingContext } from '@/platform/billing/composables/useBillingContext'
5 : import { registerRefreshOnReturn } from '@/platform/billing/refreshOnReturn'
6 : import { isCloud } from '@/platform/distribution/types'
7 :
8 : /** On local, re-reads plan, balance and capabilities on each return to this tab or window. */
9 6 : export function useRefreshBillingOnReturn(): void {
10 : if (isCloud) return
11 6 : const billing = useBillingContext()
12 6 : onScopeDispose(
13 : registerRefreshOnReturn(async (returned) => {
14 0 : if (!billing.isInitialized.value) return
15 0 : await refreshBillingAccount(returned)
16 : })
17 : )
18 : }
|