From 0368292bf19602cb207c125befacd4595804ef99 Mon Sep 17 00:00:00 2001 From: Sapphire Date: Sat, 21 Nov 2026 17:37:05 -0500 Subject: [PATCH] Toggle to show battery runtime estimate instead of percentage --- gui/app/public/i18n/en/translation.ftl | 1 + .../settings/pages/components/HomeLayoutSettings.tsx | 3 +++ gui/app/src/components/tracker/TrackerBattery.tsx | 8 ++++---- gui/app/src/hooks/config.ts | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gui/app/public/i18n/en/translation.ftl b/gui/app/public/i18n/en/translation.ftl index 5b4b4deab..2e5905bf8 100644 --- a/gui/app/public/i18n/en/translation.ftl +++ b/gui/app/public/i18n/en/translation.ftl @@ -1154,6 +1154,7 @@ settings-home-table_columns-desc = Choose which columns are shown in the tracker settings-home-display_group = Display settings-home-tracker_display = Tracker info settings-home-tracker_display-desc = Choose which extra details are shown on trackers +settings-home-tracker_display-battery_runtime_estimate = Battery runtime estimate settings-home-tracker_display-battery_voltage = Battery voltage settings-home-tracker_display-numeric_signal = Numeric signal strength diff --git a/gui/app/src/components/settings/pages/components/HomeLayoutSettings.tsx b/gui/app/src/components/settings/pages/components/HomeLayoutSettings.tsx index 07c90a5c8..7cd1124f9 100644 --- a/gui/app/src/components/settings/pages/components/HomeLayoutSettings.tsx +++ b/gui/app/src/components/settings/pages/components/HomeLayoutSettings.tsx @@ -123,11 +123,14 @@ export function TrackersTableColumnsSettings({ } const trackerDisplayToggleOrder: (keyof TrackerDisplayConfig)[] = [ + 'showBatteryRuntimeEstimate', 'showBatteryVoltage', 'showNumericSignal', ]; const trackerDisplayToggleLabel: Record = { + showBatteryRuntimeEstimate: + 'settings-home-tracker_display-battery_runtime_estimate', showBatteryVoltage: 'settings-home-tracker_display-battery_voltage', showNumericSignal: 'settings-home-tracker_display-numeric_signal', }; diff --git a/gui/app/src/components/tracker/TrackerBattery.tsx b/gui/app/src/components/tracker/TrackerBattery.tsx index 4fc48b5c3..9c7fd727a 100644 --- a/gui/app/src/components/tracker/TrackerBattery.tsx +++ b/gui/app/src/components/tracker/TrackerBattery.tsx @@ -33,14 +33,14 @@ export function TrackerBattery({ }); const charging = (voltage || 0) > 4.3; - const debug = config?.debug; + const showRuntime = config?.trackerDisplay?.showBatteryRuntimeEstimate; const showVoltage = voltage && config?.trackerDisplay?.showBatteryVoltage; const pct = value > 2 ? 0 : Math.min(Math.max(value, 0), 1); return ( {percentFormatter.format(pct)}} > @@ -50,7 +50,7 @@ export function TrackerBattery({ {((!charging || showVoltage) && (
- {!charging && runtime != null && runtime > 0 && ( + {!charging && runtime != null && runtime > 0 && showRuntime && ( {(runtime / BigInt(3600000000)).toString() + 'h ' + @@ -61,7 +61,7 @@ export function TrackerBattery({ 'min'} )} - {!charging && (!runtime || debug) && ( + {!charging && (!runtime || !showRuntime) && ( {percentFormatter.format(pct)} diff --git a/gui/app/src/hooks/config.ts b/gui/app/src/hooks/config.ts index dabaf1322..a3af47acd 100644 --- a/gui/app/src/hooks/config.ts +++ b/gui/app/src/hooks/config.ts @@ -69,11 +69,13 @@ export const trackersTableColumnOrder = [ export type TrackersTableOptionalColumn = (typeof trackersTableColumnOrder)[number]; export interface TrackerDisplayConfig { + showBatteryRuntimeEstimate: boolean; showBatteryVoltage: boolean; showNumericSignal: boolean; } export const defaultTrackerDisplay: TrackerDisplayConfig = { + showBatteryRuntimeEstimate: true, showBatteryVoltage: false, showNumericSignal: false, };