Fix BatteryWidget
This commit is contained in:
@@ -37,21 +37,16 @@ export const BatteryWidget = ({
|
|||||||
} else {
|
} else {
|
||||||
previousStat = stat.batteryLevel;
|
previousStat = stat.batteryLevel;
|
||||||
previousTime = stat.timestamp;
|
previousTime = stat.timestamp;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentStat && previousStat) {
|
if (currentStat && previousStat) {
|
||||||
const timeDiff = currentTime.getTime() - previousTime.getTime();
|
const timeDiff = currentTime.getTime() - previousTime.getTime();
|
||||||
const statDiff = Math.abs(currentStat - previousStat);
|
const statDiff = Math.abs(currentStat - previousStat);
|
||||||
//
|
|
||||||
console.log(`timeDiff: ${timeDiff}`);
|
|
||||||
console.log(`statDiff: ${statDiff}`);
|
|
||||||
|
|
||||||
//convert to ms/%
|
//convert to ms/%
|
||||||
const msPerPercent = timeDiff / statDiff;
|
const msPerPercent = timeDiff / statDiff;
|
||||||
console.log(`msPerPercent: ${msPerPercent}`);
|
|
||||||
const formatted = prettyMilliseconds(
|
const formatted = prettyMilliseconds(
|
||||||
(100 - currentStat) * msPerPercent
|
(100 - currentStat) * msPerPercent
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user