@@ -238,11 +238,11 @@ const keysSlice = createSlice({
238
238
state . deleting = false
239
239
} ,
240
240
deletePatternKeyFromList : ( state , { payload } ) => {
241
- remove ( state . data ?. keys , ( key ) => isEqualBuffers ( key . name , payload ) )
241
+ remove ( state . data ?. keys , ( key ) => isEqualBuffers ( key . name as RedisResponseBuffer , payload ) )
242
242
243
243
state . data = {
244
244
...state . data ,
245
- total : state . data . total - 1 ,
245
+ total : Math . max ( state . data . total - 1 , 0 ) ,
246
246
scanned : state . data . scanned - 1 ,
247
247
}
248
248
} ,
@@ -271,9 +271,12 @@ const keysSlice = createSlice({
271
271
} ,
272
272
editPatternKeyFromList : ( state , { payload } ) => {
273
273
const keys = state . data . keys . map ( ( key ) => {
274
- if ( isEqualBuffers ( key . name , payload ?. key ) ) {
275
- key . name = payload ?. newKey
276
- key . nameString = bufferToString ( payload ?. newKey )
274
+ if ( isEqualBuffers ( key . name as RedisResponseBuffer , payload ?. key ) ) {
275
+ return {
276
+ ...key ,
277
+ name : payload ?. newKey ,
278
+ nameString : bufferToString ( payload ?. newKey )
279
+ }
277
280
}
278
281
return key
279
282
} )
@@ -286,7 +289,7 @@ const keysSlice = createSlice({
286
289
287
290
editPatternKeyTTLFromList : ( state , { payload : [ key , ttl ] } : PayloadAction < [ RedisResponseBuffer , number ] > ) => {
288
291
const keys = state . data . keys . map ( ( keyData ) => {
289
- if ( isEqualBuffers ( keyData . name , key ) ) {
292
+ if ( isEqualBuffers ( keyData . name as RedisResponseBuffer , key ) ) {
290
293
keyData . ttl = ttl
291
294
}
292
295
return keyData
@@ -348,12 +351,12 @@ const keysSlice = createSlice({
348
351
state . filter = payload
349
352
} ,
350
353
351
- changeKeyViewType : ( state , { payload } :{ payload : KeyViewType } ) => {
354
+ changeKeyViewType : ( state , { payload } : { payload : KeyViewType } ) => {
352
355
state . viewType = payload
353
356
localStorageService ?. set ( BrowserStorageItem . browserViewType , payload )
354
357
} ,
355
358
356
- changeSearchMode : ( state , { payload } :{ payload : SearchMode } ) => {
359
+ changeSearchMode : ( state , { payload } : { payload : SearchMode } ) => {
357
360
state . searchMode = payload
358
361
} ,
359
362
@@ -541,7 +544,7 @@ export function fetchPatternKeysAction(
541
544
if ( isStatusSuccessful ( status ) ) {
542
545
dispatch (
543
546
loadKeysSuccess ( {
544
- data : parseKeysListResponse ( { } , data ) ,
547
+ data : parseKeysListResponse ( { } , data as never [ ] ) ,
545
548
isSearched : ! ! match ,
546
549
isFiltered : ! ! type ,
547
550
} )
@@ -571,7 +574,8 @@ export function fetchPatternKeysAction(
571
574
}
572
575
onSuccess ?.( data )
573
576
}
574
- } catch ( error ) {
577
+ } catch ( _err ) {
578
+ const error = _err as AxiosError
575
579
if ( ! axios . isCancel ( error ) ) {
576
580
const errorMessage = getApiErrorMessage ( error )
577
581
dispatch ( addErrorNotification ( error ) )
@@ -632,7 +636,8 @@ export function fetchMorePatternKeysAction(oldKeys: IKeyPropTypes[] = [], cursor
632
636
}
633
637
} )
634
638
}
635
- } catch ( error ) {
639
+ } catch ( _err ) {
640
+ const error = _err as AxiosError
636
641
if ( ! axios . isCancel ( error ) ) {
637
642
const errorMessage = getApiErrorMessage ( error )
638
643
dispatch ( addErrorNotification ( error ) )
@@ -732,10 +737,12 @@ export function refreshKeyInfoAction(key: RedisResponseBuffer) {
732
737
dispatch ( refreshKeyInfoSuccess ( data ) )
733
738
dispatch ( updateSelectedKeyRefreshTime ( Date . now ( ) ) )
734
739
}
735
- } catch ( error ) {
740
+ } catch ( _err ) {
741
+ const error = _err as AxiosError
736
742
dispatch ( refreshKeyInfoFail ( ) )
737
743
dispatch ( addErrorNotification ( error ) )
738
- if ( isStatusNotFoundError ( get ( error , [ 'response' , 'status' ] ) ) ) {
744
+ const status = get ( error , [ 'response' , 'status' ] )
745
+ if ( status && isStatusNotFoundError ( status ) ) {
739
746
dispatch ( resetKeyInfo ( ) )
740
747
dispatch ( deleteKeyFromList ( key ) )
741
748
}
@@ -783,7 +790,8 @@ function addTypedKey(
783
790
}
784
791
} )
785
792
}
786
- } catch ( error ) {
793
+ } catch ( _err ) {
794
+ const error = _err as AxiosError
787
795
if ( onFailAction ) {
788
796
onFailAction ( )
789
797
}
@@ -885,7 +893,8 @@ export function deleteSelectedKeyAction(
885
893
onSuccessAction ?.( )
886
894
dispatch ( addMessageNotification ( successMessages . DELETED_KEY ( key ) ) )
887
895
}
888
- } catch ( error ) {
896
+ } catch ( _err ) {
897
+ const error = _err as AxiosError
889
898
const errorMessage = getApiErrorMessage ( error as AxiosError )
890
899
dispatch ( addErrorNotification ( error as AxiosError ) )
891
900
dispatch ( deleteSelectedKeyFailure ( errorMessage ) )
@@ -920,7 +929,8 @@ export function deleteKeyAction(
920
929
onSuccessAction ?.( )
921
930
dispatch ( addMessageNotification ( successMessages . DELETED_KEY ( key ) ) )
922
931
}
923
- } catch ( error ) {
932
+ } catch ( _err ) {
933
+ const error = _err as AxiosError
924
934
dispatch ( addErrorNotification ( error as AxiosError ) )
925
935
dispatch ( deleteKeyFailure ( ) )
926
936
}
@@ -953,7 +963,8 @@ export function editKey(
953
963
dispatch < any > ( editKeyFromList ( { key, newKey } ) )
954
964
onSuccess ?.( )
955
965
}
956
- } catch ( error ) {
966
+ } catch ( _err ) {
967
+ const error = _err as AxiosError
957
968
const errorMessage = getApiErrorMessage ( error )
958
969
dispatch ( addErrorNotification ( error ) )
959
970
dispatch ( defaultSelectedKeyActionFailure ( errorMessage ) )
@@ -1000,7 +1011,8 @@ export function editKeyTTL(key: RedisResponseBuffer, ttl: number) {
1000
1011
}
1001
1012
dispatch ( defaultSelectedKeyActionSuccess ( ) )
1002
1013
}
1003
- } catch ( error ) {
1014
+ } catch ( _err ) {
1015
+ const error = _err as AxiosError
1004
1016
const errorMessage = getApiErrorMessage ( error )
1005
1017
dispatch ( addErrorNotification ( error ) )
1006
1018
dispatch ( defaultSelectedKeyActionFailure ( errorMessage ) )
@@ -1055,7 +1067,7 @@ export function fetchKeysMetadataTree(
1055
1067
state . connections . instances ?. connectedInstance ?. id ,
1056
1068
ApiEndpoints . KEYS_METADATA
1057
1069
) ,
1058
- { keys : keys . map ( ( [ , nameBuffer ] ) => nameBuffer ) , type : filter || undefined } ,
1070
+ { keys : keys . map ( ( [ , nameBuffer ] ) => nameBuffer ) , type : filter || undefined } ,
1059
1071
{ params : { encoding : state . app . info . encoding } , signal }
1060
1072
)
1061
1073
0 commit comments