Skip to content

Commit

Permalink
battery-indicator: Fix situation where unconfigured widget toggles wi…
Browse files Browse the repository at this point in the history
…thout interval
  • Loading branch information
rafaellehmkuhl committed Oct 4, 2024
1 parent dfe3941 commit f79e767
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/mini-widgets/BatteryIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,20 @@ const props = defineProps<{
}>()
const miniWidget = toRefs(props).miniWidget
const defaultOptions = {
showCurrent: true,
showPower: true,
toggleInterval: 1000,
}
const store = useMainVehicleStore()
const widgetStore = useWidgetManagerStore()
const interfaceStore = useAppInterfaceStore()
const showVoltageAndCurrent = ref(true)
const toggleIntervaler = ref<ReturnType<typeof setInterval> | undefined>(undefined)
const minInterval = 500
const toggleInterval = ref(miniWidget.value.options.toggleInterval)
const toggleInterval = ref(miniWidget.value.options.toggleInterval ?? defaultOptions.toggleInterval)
const voltageDisplayValue = computed(() => {
if (store?.powerSupply?.voltage === undefined) return NaN
Expand Down Expand Up @@ -151,13 +157,6 @@ const validateToggleInterval = (value: number): void => {
}
onBeforeMount(() => {
// Set default options if not already set
const defaultOptions = {
showVoltageAndCurrent: true,
showPowerAndConsumption: true,
toggleInterval: 3000,
}
// If both show options are disabled, use default options
if (!miniWidget.value.options.showVoltageAndCurrent && !miniWidget.value.options.showPowerAndConsumption) {
miniWidget.value.options = { ...defaultOptions }
Expand Down

0 comments on commit f79e767

Please sign in to comment.