uninstall redux-persist, weil nimmt viel Performance weg
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// /redux/slices/analogInputs/analogInputsHistory.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { getAnalogInputsHistoryThunk } from "../thunks/getAnalogInputsHistoryThunk";
|
||||
import { getAnalogInputsHistoryThunk } from "../../thunks/getAnalogInputsHistoryThunk";
|
||||
|
||||
export type AnalogInputsHistoryEntry = {
|
||||
t: string;
|
||||
@@ -7,6 +8,7 @@ export type AnalogInputsHistoryEntry = {
|
||||
};
|
||||
|
||||
export interface InputHistoryState {
|
||||
selectedId: number | null;
|
||||
zeitraum: string;
|
||||
vonDatum: string;
|
||||
bisDatum: string;
|
||||
@@ -16,6 +18,7 @@ export interface InputHistoryState {
|
||||
}
|
||||
|
||||
const initialState: InputHistoryState = {
|
||||
selectedId: null,
|
||||
zeitraum: "DIA0",
|
||||
vonDatum: "",
|
||||
bisDatum: "",
|
||||
@@ -28,6 +31,9 @@ export const analogInputsHistorySlice = createSlice({
|
||||
name: "analogInputsHistory",
|
||||
initialState,
|
||||
reducers: {
|
||||
setSelectedId: (state, action: PayloadAction<number | null>) => {
|
||||
state.selectedId = action.payload;
|
||||
},
|
||||
setZeitraum: (state, action: PayloadAction<string>) => {
|
||||
state.zeitraum = action.payload;
|
||||
},
|
||||
@@ -56,7 +62,11 @@ export const analogInputsHistorySlice = createSlice({
|
||||
},
|
||||
});
|
||||
|
||||
export const { setZeitraum, setVonDatum, setBisDatum } =
|
||||
analogInputsHistorySlice.actions;
|
||||
export const {
|
||||
setSelectedId,
|
||||
setZeitraum,
|
||||
setVonDatum,
|
||||
setBisDatum,
|
||||
} = analogInputsHistorySlice.actions;
|
||||
|
||||
export default analogInputsHistorySlice.reducer;
|
||||
@@ -1,4 +1,4 @@
|
||||
// Redux Slice: redux/slices/analogInputsSlice.ts
|
||||
// Redux Slice: redux/slices/analogInputs/analogInputsSlice.ts
|
||||
import { createSlice, PayloadAction, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import type { AnalogInput } from "@/types/analogInput";
|
||||
|
||||
23
redux/slices/analogInputs/analogInputsUiSlice.ts
Normal file
23
redux/slices/analogInputs/analogInputsUiSlice.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// /redux/slices/analogInputs/analogInputsUiSlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
interface AnalogInputsUiState {
|
||||
isSettingsModalOpen: boolean;
|
||||
}
|
||||
|
||||
const initialState: AnalogInputsUiState = {
|
||||
isSettingsModalOpen: false,
|
||||
};
|
||||
|
||||
const analogInputsUiSlice = createSlice({
|
||||
name: "analogInputsUi",
|
||||
initialState,
|
||||
reducers: {
|
||||
setIsSettingsModalOpen: (state, action: PayloadAction<boolean>) => {
|
||||
state.isSettingsModalOpen = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setIsSettingsModalOpen } = analogInputsUiSlice.actions;
|
||||
export default analogInputsUiSlice.reducer;
|
||||
34
redux/slices/analogInputs/selectedAnalogInputSlice.ts
Normal file
34
redux/slices/analogInputs/selectedAnalogInputSlice.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
// redux/slices/analogInputs/selectedAnalogInputSlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import type { AnalogInput } from "@/types/analogInput";
|
||||
|
||||
// Anfangszustand: noch kein Eingang ausgewählt
|
||||
const initialState: AnalogInput = {
|
||||
id: 0,
|
||||
label: "",
|
||||
value: 0,
|
||||
name: "",
|
||||
};
|
||||
|
||||
const selectedAnalogInputSlice = createSlice({
|
||||
name: "selectedAnalogInput",
|
||||
initialState,
|
||||
reducers: {
|
||||
setSelectedAnalogInput(state, action: PayloadAction<AnalogInput>) {
|
||||
if (state) {
|
||||
// Mutiert vorhandene Struktur (optional, wenn initialState nicht null sein darf)
|
||||
Object.assign(state, action.payload);
|
||||
} else {
|
||||
return action.payload;
|
||||
}
|
||||
},
|
||||
clearSelectedAnalogInput() {
|
||||
return initialState;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setSelectedAnalogInput, clearSelectedAnalogInput } =
|
||||
selectedAnalogInputSlice.actions;
|
||||
|
||||
export default selectedAnalogInputSlice.reducer;
|
||||
@@ -1,29 +0,0 @@
|
||||
// /redux/slices/selectedAnalogInputSlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
type SelectedAnalogInput = {
|
||||
id: number;
|
||||
label: string;
|
||||
status: boolean;
|
||||
loggerInterval: number;
|
||||
};
|
||||
|
||||
const initialState: SelectedAnalogInput | null = null;
|
||||
// @ts-expect-error 123
|
||||
const selectedAnalogInputSlice = createSlice<SelectedAnalogInput | null>({
|
||||
name: "selectedAnalogInput",
|
||||
initialState,
|
||||
reducers: {
|
||||
setSelectedAnalogInput: (
|
||||
_state,
|
||||
action: PayloadAction<SelectedAnalogInput>
|
||||
) => action.payload,
|
||||
|
||||
resetSelectedAnalogInput: () => null,
|
||||
},
|
||||
});
|
||||
|
||||
export const { setSelectedAnalogInput, resetSelectedAnalogInput } =
|
||||
selectedAnalogInputSlice.actions;
|
||||
|
||||
export default selectedAnalogInputSlice.reducer;
|
||||
Reference in New Issue
Block a user