mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
refactor(frontend): remove the code-slice.ts file (#11021)
This commit is contained in:
parent
0061bcc0b0
commit
a8a3e9e604
@ -1,58 +0,0 @@
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
export interface FileState {
|
||||
path: string;
|
||||
savedContent: string;
|
||||
unsavedContent: string;
|
||||
}
|
||||
|
||||
export const initialState = {
|
||||
code: "",
|
||||
path: "",
|
||||
refreshID: 0,
|
||||
fileStates: [] as FileState[],
|
||||
};
|
||||
|
||||
export const codeSlice = createSlice({
|
||||
name: "code",
|
||||
initialState,
|
||||
reducers: {
|
||||
setCode: (state, action) => {
|
||||
state.code = action.payload;
|
||||
},
|
||||
setActiveFilepath: (state, action) => {
|
||||
state.path = action.payload;
|
||||
},
|
||||
setRefreshID: (state, action) => {
|
||||
state.refreshID = action.payload;
|
||||
},
|
||||
setFileStates: (state, action) => {
|
||||
state.fileStates = action.payload;
|
||||
},
|
||||
addOrUpdateFileState: (state, action) => {
|
||||
const { path, unsavedContent, savedContent } = action.payload;
|
||||
const newFileStates = state.fileStates.filter(
|
||||
(fileState) => fileState.path !== path,
|
||||
);
|
||||
newFileStates.push({ path, savedContent, unsavedContent });
|
||||
state.fileStates = newFileStates;
|
||||
},
|
||||
removeFileState: (state, action) => {
|
||||
const path = action.payload;
|
||||
state.fileStates = state.fileStates.filter(
|
||||
(fileState) => fileState.path !== path,
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
setCode,
|
||||
setActiveFilepath,
|
||||
setRefreshID,
|
||||
addOrUpdateFileState,
|
||||
removeFileState,
|
||||
setFileStates,
|
||||
} = codeSlice.actions;
|
||||
|
||||
export default codeSlice.reducer;
|
||||
@ -1,7 +1,6 @@
|
||||
import { combineReducers, configureStore } from "@reduxjs/toolkit";
|
||||
import agentReducer from "./state/agent-slice";
|
||||
import browserReducer from "./state/browser-slice";
|
||||
import codeReducer from "./state/code-slice";
|
||||
import fileStateReducer from "./state/file-state-slice";
|
||||
import initialQueryReducer from "./state/initial-query-slice";
|
||||
import commandReducer from "./state/command-slice";
|
||||
@ -17,7 +16,6 @@ export const rootReducer = combineReducers({
|
||||
fileState: fileStateReducer,
|
||||
initialQuery: initialQueryReducer,
|
||||
browser: browserReducer,
|
||||
code: codeReducer,
|
||||
cmd: commandReducer,
|
||||
agent: agentReducer,
|
||||
jupyter: jupyterReducer,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user