@@ -17,6 +17,11 @@ export interface FnGlobalState {
17
17
hiddenVariables : string [ ] ;
18
18
}
19
19
20
+ export type UpdateFNGlobalStateAction = PayloadAction < {
21
+ type : keyof FnGlobalState ;
22
+ payload : FnGlobalState [ keyof FnGlobalState ] ;
23
+ } > ;
24
+
20
25
const INITIAL_MODE = GrafanaThemeType . Light ;
21
26
22
27
const initialState : FnGlobalState = {
@@ -34,13 +39,10 @@ const fnSlice = createSlice({
34
39
name : 'fnGlobalState' ,
35
40
initialState,
36
41
reducers : {
37
- setInitialMountState : ( state , action : PayloadAction < Omit < FnGlobalState , " hiddenVariables" > > ) => {
42
+ setInitialMountState : ( state , action : PayloadAction < Omit < FnGlobalState , ' hiddenVariables' > > ) => {
38
43
return { ...state , ...action . payload } ;
39
44
} ,
40
- updateFnState : (
41
- state : WritableDraft < FnGlobalState > ,
42
- action : PayloadAction < { type : keyof FnGlobalState ; payload : FnGlobalState [ keyof FnGlobalState ] } >
43
- ) => {
45
+ updateFnState : ( state : WritableDraft < FnGlobalState > , action : UpdateFNGlobalStateAction ) => {
44
46
const { type, payload } = action . payload ;
45
47
46
48
return {
@@ -54,14 +56,14 @@ const fnSlice = createSlice({
54
56
export const { updateFnState, setInitialMountState } = fnSlice . actions ;
55
57
export const fnSliceReducer = fnSlice . reducer ;
56
58
57
- export const updateFNGlobalState =
58
- (
59
- type : keyof FnGlobalState ,
60
- payload : string | boolean | AnyObject < string , any > | string [ ] | null
61
- ) =>
62
- {
63
- dispatch ( updateFnState ( {
64
- type ,
65
- payload ,
66
- } ) ) ;
67
- }
59
+ export const updateFNGlobalState = (
60
+ type : keyof FnGlobalState ,
61
+ payload : UpdateFNGlobalStateAction [ 'payload' ] [ 'payload' ]
62
+ ) : void => {
63
+ dispatch (
64
+ updateFnState ( {
65
+ type ,
66
+ payload ,
67
+ } )
68
+ ) ;
69
+ } ;
0 commit comments