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

Commit

Permalink
feat: Battery saver feature is working. (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
git-init-priyanshu authored Oct 16, 2023
1 parent 964d0b1 commit 4a5720e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/components/start/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export const SidePane = () => {
Actions[action.type](action.payload);
} else dispatch(action);
}
// For battery saver
if (action.payload === "system.power.saver.state") setBrightness();
};

const vSlider = document.querySelector(".vSlider");
Expand All @@ -153,7 +155,21 @@ export const SidePane = () => {
}

const setBrightness = (e) => {
var brgt = e.target.value;
var brgt = document.getElementById("brightnessSlider").value;
if (!e) {
// Battery saver
const state = setting.system.power.saver.state;
const factor = state ? 0.7 : 100 / 70;
const newBrgt = brgt * factor;
setBrightnessValue(newBrgt);
document.getElementById("brightnessSlider").value = newBrgt;
} else {
// Brightness slider
setBrightnessValue(brgt);
}
};

function setBrightnessValue(brgt) {
document.getElementById("brightoverlay").style.opacity = (100 - brgt) / 100;
dispatch({
type: "STNGSETV",
Expand Down Expand Up @@ -220,6 +236,7 @@ export const SidePane = () => {
<div className="sliderCont">
<Icon className="mx-2" src="brightness" ui width={20} />
<input
id="brightnessSlider"
className="sliders bSlider"
onChange={setBrightness}
type="range"
Expand Down
1 change: 0 additions & 1 deletion src/reducers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const settReducer = (state = defState, action) => {
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");
}
Expand Down

0 comments on commit 4a5720e

Please sign in to comment.