File size: 613 Bytes
246d201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

type SliceState = { changed: Record<string, boolean> }; // Map<path, changed>

const initialState: SliceState = {
  changed: {},
};

export const fileStateSlice = createSlice({
  name: "fileState",
  initialState,
  reducers: {
    setChanged(

      state,

      action: PayloadAction<{ path: string; changed: boolean }>,

    ) {
      const { path, changed } = action.payload;
      state.changed[path] = changed;
    },
  },
});

export const { setChanged } = fileStateSlice.actions;
export default fileStateSlice.reducer;