Browse Source

Fix BatteryWidget

pull/43/head
Sacha Weatherstone 4 years ago
parent
commit
b6811c17d3
  1. 7
      src/components/Widgets/BatteryWidget.tsx

7
src/components/Widgets/BatteryWidget.tsx

@ -37,21 +37,16 @@ export const BatteryWidget = ({
} else {
previousStat = stat.batteryLevel;
previousTime = stat.timestamp;
break;
}
break;
}
}
if (currentStat && previousStat) {
const timeDiff = currentTime.getTime() - previousTime.getTime();
const statDiff = Math.abs(currentStat - previousStat);
//
console.log(`timeDiff: ${timeDiff}`);
console.log(`statDiff: ${statDiff}`);
//convert to ms/%
const msPerPercent = timeDiff / statDiff;
console.log(`msPerPercent: ${msPerPercent}`);
const formatted = prettyMilliseconds(
(100 - currentStat) * msPerPercent
);

Loading…
Cancel
Save