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

feat: Battery saver feature is working. #812

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading