2022-02-27 06:17:52 +00:00
|
|
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit"
|
|
|
|
|
2022-03-03 04:23:06 +00:00
|
|
|
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,
|
2022-03-03 04:23:06 +00:00
|
|
|
clearPluginsTxt: () => "",
|
2022-02-27 06:17:52 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
export const { setPluginsTxt, clearPluginsTxt } = pluginsTxtSlice.actions
|
|
|
|
|
|
|
|
export const selectPluginsTxt = (state: AppState) => state.pluginsTxt
|
|
|
|
|
2022-03-03 04:23:06 +00:00
|
|
|
export const setPluginsTxtAndApplyLoadOrder = (pluginsTxt: string): AppThunk => (dispatch) => {
|
|
|
|
dispatch(setPluginsTxt(pluginsTxt));
|
|
|
|
dispatch(applyLoadOrder());
|
|
|
|
}
|
|
|
|
|
2022-02-27 06:17:52 +00:00
|
|
|
export default pluginsTxtSlice.reducer
|