Skip to content

Commit b677734

Browse files
committed
fix(billing): skip the activity refresh on first balance hydration
UsageLogsTable now loads itself, so refreshing again when the balance first resolves fetched activity twice per panel open.
1 parent 4469de4 commit b677734

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/components/dialog/content/setting/CreditsPanel.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ describe('CreditsPanel', () => {
103103
expect(billingMocks.manageSubscription).toHaveBeenCalledOnce()
104104
})
105105

106-
it('refreshes activity when the rendered balance changes', async () => {
106+
it('refreshes activity on a balance change but not on first hydration', async () => {
107107
renderComponent()
108-
expect(refreshActivity).not.toHaveBeenCalled()
109108

110109
billingMocks.balance.value = makeBalance(5000)
111110
await nextTick()
111+
expect(refreshActivity).not.toHaveBeenCalled()
112112

113+
billingMocks.balance.value = makeBalance(9000)
114+
await nextTick()
113115
expect(refreshActivity).toHaveBeenCalledOnce()
114116
})
115117
})

src/components/dialog/content/setting/CreditsPanel.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ const telemetry = useTelemetry()
5555
5656
const usageLogsTableRef = ref<InstanceType<typeof UsageLogsTable> | null>(null)
5757
58-
watch(balance, () => {
58+
watch(balance, (next, previous) => {
59+
if (!next || !previous) return
5960
void usageLogsTableRef.value?.refresh()
6061
})
6162

0 commit comments

Comments
 (0)