modmapper-web/slices/pluginsTxt.ts

28 lines
811 B
TypeScript
Raw Normal View History

2022-02-27 06:17:52 +00:00
import { createSlice, PayloadAction } from "@reduxjs/toolkit"
import type { AppState, AppThunk } from "../lib/store"
import { applyLoadOrder } from "./plugins";
2022-02-27 06:17:52 +00:00
export type PluginsTxtState = string;
const initialState: PluginsTxtState = "";
export const pluginsTxtSlice = createSlice({
name: "pluginsTxt",
initialState,
reducers: {
setPluginsTxt: (state, action: PayloadAction<string>) => action.payload,
clearPluginsTxt: () => "",
2022-02-27 06:17:52 +00:00
},
})
export const { setPluginsTxt, clearPluginsTxt } = pluginsTxtSlice.actions
export const selectPluginsTxt = (state: AppState) => state.pluginsTxt
export const setPluginsTxtAndApplyLoadOrder = (pluginsTxt: string): AppThunk => (dispatch) => {
dispatch(setPluginsTxt(pluginsTxt));
dispatch(applyLoadOrder());
}
2022-02-27 06:17:52 +00:00
export default pluginsTxtSlice.reducer