diff --git a/Dashboard/src/Components/KnobSection.tsx b/Dashboard/src/Components/KnobSection.tsx index d1c6683..e88e8d6 100644 --- a/Dashboard/src/Components/KnobSection.tsx +++ b/Dashboard/src/Components/KnobSection.tsx @@ -21,29 +21,29 @@ const KnobSection = () => { }; useEffect(() => { - if (serialConnection.portController !== null && serialConnection.portController !== undefined) { + if (serialConnection.portController !== null) { serialConnection.portController.parser.on("data", SerialDataListener); } return () => { - if (serialConnection.portController !== null && serialConnection.portController !== undefined) { + if (serialConnection.portController !== null) { serialConnection.portController.parser.removeListener("data", SerialDataListener); } }; }, [serialConnection]); const sendIncreaseHandler = (index: number) => { - if (serialConnection.portController !== null && serialConnection.portController.port !== null && serialConnection.portController !== undefined) { + if (serialConnection.portController !== null && serialConnection.portController.port !== null) { serialConnection.portController.port.write(`${index}i`); } }; const sendDecreaseHandler = (index: number) => { - if (serialConnection.portController !== null && serialConnection.portController.port !== null && serialConnection.portController !== undefined) { + if (serialConnection.portController !== null && serialConnection.portController.port !== null) { serialConnection.portController.port.write(`${index}d`); } }; const sendToggleHandler = (index: number) => { - if (serialConnection.portController !== null && serialConnection.portController.port !== null && serialConnection.portController !== undefined) { + if (serialConnection.portController !== null && serialConnection.portController.port !== null) { serialConnection.portController.port.write(`${index}t`); } }; diff --git a/Dashboard/src/redux/store/index.ts b/Dashboard/src/redux/store/index.ts index 1e2bdb5..4f50ee4 100644 --- a/Dashboard/src/redux/store/index.ts +++ b/Dashboard/src/redux/store/index.ts @@ -1,11 +1,10 @@ import thunk from "redux-thunk"; import { createStore, applyMiddleware } from "redux"; import { RootAction, RootState } from "typesafe-actions"; -import { persistStore, persistReducer, createTransform } from "redux-persist"; +import { persistStore, persistReducer } from "redux-persist"; import createElectronStorage from "redux-persist-electron-storage"; import ElectronStore from "electron-store"; -import omit from "lodash/omit"; import composeEnhancers from "./utils"; import rootReducer from "./root-reducer"; @@ -19,20 +18,12 @@ createElectronStorage({ electronStore, }); -const blacklistPaths = ["serialConnection.portController", "serialConnection.status"]; const persistConfig = { - key: "root", + key: "serialConnection", storage: createElectronStorage({ electronStore, }), - blacklist: blacklistPaths.filter((a) => !a.includes(".")), - transforms: [ - // nested blacklist-paths require a custom transform to be applied - createTransform((inboundState: object, key) => { - const blacklistPathsForKey = blacklistPaths.filter((path) => path.startsWith(`${String(key)}.`)).map((path) => path.substr(String(key).length + 1)); - return omit(inboundState, ...blacklistPathsForKey); - }, null), - ], + blacklist: ["portController"], }; export const persistedReducer = persistReducer(persistConfig, rootReducer);