Skip to content

Commit 1f93204

Browse files
committed
fix(ui): prevent double API call on refresh button click
handleRefreshClick is now a no-op since AutoRefresh.handleRefreshClick already calls onRefresh() before onRefreshClicked(), which means loadData() is already triggered via handleRefresh. References: #RI-7761
1 parent 59b442b commit 1f93204

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

redisinsight/ui/src/components/database-overview/hooks/useDatabaseOverview.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ describe('useDatabaseOverview', () => {
158158
expect(actions).toContainEqual(getDatabaseConfigInfo())
159159
})
160160

161-
it('should handle refresh click correctly', () => {
162-
// Clear previous actions
161+
it('should handle refresh click correctly (no-op)', () => {
162+
// handleRefreshClick is intentionally a no-op.
163+
// AutoRefresh.handleRefreshClick calls onRefresh() before onRefreshClicked(),
164+
// so loadData() is already called via handleRefresh.
163165
mockedStore.clearActions()
164166

165167
const data = renderHelper(mockedStore)
@@ -168,9 +170,8 @@ describe('useDatabaseOverview', () => {
168170
})
169171

170172
const actions = mockedStore.getActions()
171-
// handleRefreshClick now calls loadData which dispatches getDatabaseConfigInfo
172-
// The connectivity error will be cleared on successful API response
173-
expect(actions).toContainEqual(getDatabaseConfigInfo())
173+
// handleRefreshClick should not dispatch any actions
174+
expect(actions).toHaveLength(0)
174175
})
175176

176177
it('should send telemetry event when auto-refresh is enabled', () => {

redisinsight/ui/src/components/database-overview/hooks/useDatabaseOverview.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ export const useDatabaseOverview = () => {
8585
const handleRefresh = () => {
8686
loadData()
8787
}
88-
const handleRefreshClick = () => {
89-
loadData()
90-
}
88+
// Note: handleRefreshClick is intentionally a no-op.
89+
// AutoRefresh.handleRefreshClick calls onRefresh() before onRefreshClicked(),
90+
// so loadData() is already called via handleRefresh. This callback exists only
91+
// for cases where additional side effects are needed on manual click.
92+
const handleRefreshClick = () => {}
9193
const usedMemoryPercent = getUsedMemoryPercent(
9294
planMemoryLimit,
9395
usedMemory,

0 commit comments

Comments
 (0)