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,