Skip to content

Commit 59b442b

Browse files
committed
fix(ui): auto-clear connection error when Redis reconnects
Remove the connectivityError guard that prevented auto-refresh from making API calls during errors. Now auto-refresh continues during errors and clears the error indicator on successful API response. References: #RI-7761
1 parent f7ba473 commit 59b442b

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ describe('useDatabaseOverview', () => {
168168
})
169169

170170
const actions = mockedStore.getActions()
171-
expect(actions).toContainEqual(setConnectivityError(null))
171+
// handleRefreshClick now calls loadData which dispatches getDatabaseConfigInfo
172+
// The connectivity error will be cleared on successful API response
173+
expect(actions).toContainEqual(getDatabaseConfigInfo())
172174
})
173175

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

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@ export const useDatabaseOverview = () => {
4848
} = {},
4949
} = overview
5050

51-
const loadData = (forceDataReload = false) => {
52-
if (connectedInstanceId && (!connectivityError || forceDataReload)) {
53-
dispatch(getDatabaseConfigInfoAction(connectedInstanceId))
51+
const loadData = () => {
52+
if (connectedInstanceId) {
53+
dispatch(
54+
getDatabaseConfigInfoAction(connectedInstanceId, () => {
55+
// Clear connectivity error on successful API call
56+
if (connectivityError) {
57+
dispatch(setConnectivityError(null))
58+
}
59+
}),
60+
)
5461
setLastRefreshTime(Date.now())
5562
}
5663
}
@@ -75,12 +82,11 @@ export const useDatabaseOverview = () => {
7582
},
7683
})
7784

78-
const handleRefresh = (forceRefresh?: boolean) => {
79-
loadData(forceRefresh)
85+
const handleRefresh = () => {
86+
loadData()
8087
}
8188
const handleRefreshClick = () => {
82-
// clear error, if connectivity is broken, the interceptor will set it again
83-
dispatch(setConnectivityError(null))
89+
loadData()
8490
}
8591
const usedMemoryPercent = getUsedMemoryPercent(
8692
planMemoryLimit,

0 commit comments

Comments
 (0)