@@ -41,6 +41,7 @@ import { fetchStreamEntries, setStreamInitialState } from './stream'
41
41
import {
42
42
deleteRedisearchKeyFromList ,
43
43
editRedisearchKeyFromList ,
44
+ editRedisearchKeyTTLFromList ,
44
45
fetchMoreRedisearchKeysAction ,
45
46
fetchRedisearchKeysAction ,
46
47
resetRedisearchKeysData ,
@@ -253,6 +254,20 @@ const keysSlice = createSlice({
253
254
}
254
255
} ,
255
256
257
+ editPatternKeyTTLFromList : ( state , { payload : [ key , ttl ] } : PayloadAction < [ RedisResponseBuffer , number ] > ) => {
258
+ const keys = state . data . keys . map ( ( keyData ) => {
259
+ if ( isEqualBuffers ( keyData . name , key ) ) {
260
+ keyData . ttl = ttl
261
+ }
262
+ return keyData
263
+ } )
264
+
265
+ state . data = {
266
+ ...state . data ,
267
+ keys,
268
+ }
269
+ } ,
270
+
256
271
// update length for Selected Key
257
272
updateSelectedKeyLength : ( state , { payload } ) => {
258
273
state . selectedKey = {
@@ -367,6 +382,7 @@ export const {
367
382
deleteKeyFailure,
368
383
deletePatternKeyFromList,
369
384
editPatternKeyFromList,
385
+ editPatternKeyTTLFromList,
370
386
updateSelectedKeyLength,
371
387
setPatternSearchMatch,
372
388
setFilter,
@@ -797,7 +813,7 @@ export function deleteKeyAction(key: RedisResponseBuffer, onSuccessAction?: () =
797
813
}
798
814
} )
799
815
dispatch ( deleteKeySuccess ( ) )
800
- dispatch ( deleteKeyFromList ( key ) )
816
+ dispatch < any > ( deleteKeyFromList ( key ) )
801
817
onSuccessAction ?.( )
802
818
dispatch ( addMessageNotification ( successMessages . DELETED_KEY ( key ) ) )
803
819
}
@@ -832,7 +848,7 @@ export function editKey(
832
848
)
833
849
834
850
if ( isStatusSuccessful ( status ) ) {
835
- dispatch ( editKeyFromList ( { key, newKey } ) )
851
+ dispatch < any > ( editKeyFromList ( { key, newKey } ) )
836
852
onSuccess ?.( )
837
853
}
838
854
} catch ( error ) {
@@ -845,7 +861,7 @@ export function editKey(
845
861
}
846
862
847
863
// Asynchronous thunk action
848
- export function editKeyTTL ( key : string , ttl : number ) {
864
+ export function editKeyTTL ( key : RedisResponseBuffer , ttl : number ) {
849
865
return async ( dispatch : AppDispatch , stateInit : ( ) => RootState ) => {
850
866
dispatch ( defaultSelectedKeyAction ( ) )
851
867
@@ -874,10 +890,11 @@ export function editKeyTTL(key: string, ttl: number) {
874
890
}
875
891
} )
876
892
if ( ttl !== 0 ) {
893
+ dispatch < any > ( editKeyTTLFromList ( [ key , ttl ] ) )
877
894
dispatch < any > ( fetchKeyInfo ( key ) )
878
895
} else {
879
896
dispatch ( deleteKeySuccess ( ) )
880
- dispatch ( deleteKeyFromList ( key ) )
897
+ dispatch < any > ( deleteKeyFromList ( key ) )
881
898
}
882
899
dispatch ( defaultSelectedKeyActionSuccess ( ) )
883
900
}
@@ -932,8 +949,8 @@ export function fetchKeys(
932
949
const isRedisearchExists = isRedisearchAvailable ( state . connections . instances . connectedInstance . modules )
933
950
934
951
return searchMode === SearchMode . Pattern || ! isRedisearchExists
935
- ? dispatch ( fetchPatternKeysAction ( cursor , count , onSuccess , onFailed ) )
936
- : dispatch ( fetchRedisearchKeysAction ( cursor , count , onSuccess , onFailed ) )
952
+ ? dispatch < any > ( fetchPatternKeysAction ( cursor , count , onSuccess , onFailed ) )
953
+ : dispatch < any > ( fetchRedisearchKeysAction ( cursor , count , onSuccess , onFailed ) )
937
954
}
938
955
}
939
956
@@ -977,12 +994,22 @@ export function deleteKeyFromList(key: RedisResponseBuffer) {
977
994
}
978
995
}
979
996
980
- export function editKeyFromList ( key : RedisResponseBuffer ) {
997
+ export function editKeyFromList ( data : { key : RedisResponseBuffer , newKey : RedisResponseBuffer } ) {
998
+ return async ( dispatch : AppDispatch , stateInit : ( ) => RootState ) => {
999
+ const state = stateInit ( )
1000
+
1001
+ return state . browser . keys ?. searchMode === SearchMode . Pattern
1002
+ ? dispatch ( editPatternKeyFromList ( data ) )
1003
+ : dispatch ( editRedisearchKeyFromList ( data ) )
1004
+ }
1005
+ }
1006
+
1007
+ export function editKeyTTLFromList ( data : [ RedisResponseBuffer , number ] ) {
981
1008
return async ( dispatch : AppDispatch , stateInit : ( ) => RootState ) => {
982
1009
const state = stateInit ( )
983
1010
984
1011
return state . browser . keys ?. searchMode === SearchMode . Pattern
985
- ? dispatch ( editPatternKeyFromList ( key ) )
986
- : dispatch ( editRedisearchKeyFromList ( key ) )
1012
+ ? dispatch ( editPatternKeyTTLFromList ( data ) )
1013
+ : dispatch ( editRedisearchKeyTTLFromList ( data ) )
987
1014
}
988
1015
}
0 commit comments