zzz / frontend /src /state /file-state-slice.ts
ar08's picture
Upload 1040 files
246d201 verified
raw
history blame contribute delete
613 Bytes
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;