summaryrefslogtreecommitdiff
path: root/extension/react-app/src/redux/slices/uiStateSlice.ts
blob: 837d19e91421111ff5c26f915ea764d4a5f17bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { createSlice } from "@reduxjs/toolkit";

export const uiStateSlice = createSlice({
  name: "uiState",
  initialState: {
    bottomMessage: undefined,
    bottomMessageCloseTimeout: undefined,
  },
  reducers: {
    setBottomMessage: (state, action) => {
      state.bottomMessage = action.payload;
    },
    setBottomMessageCloseTimeout: (state, action) => {
      if (state.bottomMessageCloseTimeout) {
        clearTimeout(state.bottomMessageCloseTimeout);
      }
      state.bottomMessageCloseTimeout = action.payload;
    },
  },
});

export const { setBottomMessage, setBottomMessageCloseTimeout } =
  uiStateSlice.actions;
export default uiStateSlice.reducer;