Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Fixed: Wi-Fi and Bluetooth toggling. (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
git-init-priyanshu authored Oct 7, 2023
1 parent 4ab630d commit 6689e29
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,7 @@ export const handleFileOpen = (id) => {
}
}
};

export const flightMode = () => {
store.dispatch({ type: "TOGGAIRPLNMD", payload: "" });
};
13 changes: 13 additions & 0 deletions src/reducers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/sidepane.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defState = {
src: "airplane",
name: "Flight Mode",
state: "network.airplane",
action: "STNGTOGG",
action: "flightMode",
},
{
ui: true,
Expand Down

0 comments on commit 6689e29

Please sign in to comment.