From 6689e290855e39bc853c760424e0cea4bfd28a34 Mon Sep 17 00:00:00 2001 From: Priyanshu Bartwal <110045644+git-init-priyanshu@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:36:01 +0530 Subject: [PATCH] Fixed: Wi-Fi and Bluetooth toggling. (#804) --- src/actions/index.js | 4 ++++ src/reducers/settings.js | 13 +++++++++++++ src/reducers/sidepane.js | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/actions/index.js b/src/actions/index.js index aa879381b..355324ccf 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -264,3 +264,7 @@ export const handleFileOpen = (id) => { } } }; + +export const flightMode = () => { + store.dispatch({ type: "TOGGAIRPLNMD", payload: "" }); +}; diff --git a/src/reducers/settings.js b/src/reducers/settings.js index 594fa1e86..7188d0d0d 100644 --- a/src/reducers/settings.js +++ b/src/reducers/settings.js @@ -72,7 +72,20 @@ const settReducer = (state = defState, action) => { tmpState = changeVal(tmpState, action.payload.path, action.payload.value); break; case "SETTLOAD": + changed = true; tmpState = { ...action.payload }; + break; + case "TOGGAIRPLNMD": + changed = true; + const airPlaneModeStatus = tmpState.network.airplane; + console.log(airPlaneModeStatus); + if (tmpState.network.wifi.state === true && !airPlaneModeStatus) { + tmpState = changeVal(tmpState, "network.wifi.state"); + } + if (tmpState.devices.bluetooth === true && !airPlaneModeStatus) { + tmpState = changeVal(tmpState, "devices.bluetooth"); + } + tmpState = changeVal(tmpState, "network.airplane"); } if (changed) localStorage.setItem("setting", JSON.stringify(tmpState)); diff --git a/src/reducers/sidepane.js b/src/reducers/sidepane.js index 07aa0ff53..1fb016cd3 100644 --- a/src/reducers/sidepane.js +++ b/src/reducers/sidepane.js @@ -19,7 +19,7 @@ const defState = { src: "airplane", name: "Flight Mode", state: "network.airplane", - action: "STNGTOGG", + action: "flightMode", }, { ui: true,