Skip to content

Commit 8483ed9

Browse files
Merge pull request #1282 from RedisInsight/fe/bugfix/RI-3595_Speed_up_initial_load
#RI-3672, #RI-3671
2 parents 82ff675 + fa8c2eb commit 8483ed9

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

redisinsight/ui/src/pages/browser/components/key-list/KeyList.spec.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,21 @@ describe('KeyList', () => {
136136
/>)
137137

138138
await waitFor(async () => {
139-
expect(apiServiceMock).toBeCalledTimes(2)
139+
expect(apiServiceMock).toBeCalledTimes(3)
140140

141141
expect(apiServiceMock.mock.calls[0]).toEqual([
142142
'/instance//keys/get-metadata',
143-
{ keys: ['key1'] },
143+
{ keys: ['key1', 'key2', 'key3'] },
144144
params,
145145
])
146146

147147
expect(apiServiceMock.mock.calls[1]).toEqual([
148+
'/instance//keys/get-metadata',
149+
{ keys: ['key1'] },
150+
params,
151+
])
152+
153+
expect(apiServiceMock.mock.calls[2]).toEqual([
148154
'/instance//keys/get-metadata',
149155
{ keys: ['key1', 'key2', 'key3'] },
150156
params,

redisinsight/ui/src/pages/browser/components/key-list/KeyList.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const KeyList = forwardRef((props: Props, ref) => {
9999
useEffect(() => {
100100
itemsRef.current = [...keysState.keys]
101101
if (itemsRef.current.length === 0) {
102+
rerender({})
102103
return
103104
}
104105

@@ -168,6 +169,7 @@ const KeyList = forwardRef((props: Props, ref) => {
168169
const newItems = bufferFormatRows(startIndex, lastIndex)
169170

170171
getMetadata(startIndex, lastIndex, newItems)
172+
rerender({})
171173
}, 100)
172174

173175
const bufferFormatRows = (startIndex: number, lastIndex: number): GetKeyInfoResponse[] => {
@@ -199,7 +201,8 @@ const KeyList = forwardRef((props: Props, ref) => {
199201
lastIndex,
200202
loadedItems,
201203
isFirstEmpty: !isSomeNotUndefined(itemsInit[0]),
202-
})
204+
}),
205+
() => { rerender({}) }
203206
))
204207
}
205208

redisinsight/ui/src/utils/formatters/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const bufferFormatRangeItems = (
44
const newItems = []
55
if (lastIndex >= startIndex) {
66
for (let index = startIndex; index <= lastIndex; index++) {
7-
if (!items[index]) return [startIndex, newItems]
7+
if (!items[index]) return newItems
88
newItems.push(formatItem(items[index]))
99
}
1010
}

0 commit comments

Comments
 (0)