diff --git a/src/components/mini-widgets/BatteryIndicator.vue b/src/components/mini-widgets/BatteryIndicator.vue
index 4c789ef56..d5d1000f2 100644
--- a/src/components/mini-widgets/BatteryIndicator.vue
+++ b/src/components/mini-widgets/BatteryIndicator.vue
@@ -30,22 +30,29 @@
Battery Indicator Config
-
+
validateToggleInterval(Number(v))"
/>
@@ -78,6 +85,8 @@ const interfaceStore = useAppInterfaceStore()
const showVoltageAndCurrent = ref(true)
const toggleIntervaler = ref | undefined>(undefined)
+const minInterval = 500
+const toggleInterval = ref(miniWidget.value.options.toggleInterval)
const voltageDisplayValue = computed(() => {
if (store?.powerSupply?.voltage === undefined) return NaN
@@ -110,6 +119,8 @@ const setupToggleInterval = (): void => {
clearInterval(toggleIntervaler.value)
}
+ toggleInterval.value = miniWidget.value.options.toggleInterval
+
if (miniWidget.value.options.showVoltageAndCurrent && miniWidget.value.options.showPowerAndConsumption) {
toggleIntervaler.value = setInterval(() => {
showVoltageAndCurrent.value = !showVoltageAndCurrent.value
@@ -121,6 +132,24 @@ const setupToggleInterval = (): void => {
watch(() => miniWidget.value.options, setupToggleInterval, { deep: true })
+const validateShowOptions = (value: boolean): void => {
+ if (!miniWidget.value.options.showVoltageAndCurrent && !miniWidget.value.options.showPowerAndConsumption) {
+ // If both options are unchecked, force the current one to be checked
+ miniWidget.value.options[value ? 'showPowerAndConsumption' : 'showVoltageAndCurrent'] = true
+ }
+}
+
+const intervalErrorMessage = ref('')
+
+const validateToggleInterval = (value: number): void => {
+ if (value < minInterval) {
+ intervalErrorMessage.value = `Interval must be at least ${minInterval}ms`
+ } else {
+ intervalErrorMessage.value = ''
+ miniWidget.value.options.toggleInterval = value
+ }
+}
+
onBeforeMount(() => {
// Set default options if not already set
const defaultOptions = {
@@ -128,7 +157,16 @@ onBeforeMount(() => {
showPowerAndConsumption: true,
toggleInterval: 3000,
}
- miniWidget.value.options = Object.assign({}, defaultOptions, miniWidget.value.options)
+
+ // If both show options are disabled, use default options
+ if (!miniWidget.value.options.showVoltageAndCurrent && !miniWidget.value.options.showPowerAndConsumption) {
+ miniWidget.value.options = { ...defaultOptions }
+ } else {
+ miniWidget.value.options = Object.assign({}, defaultOptions, miniWidget.value.options)
+ }
+
+ // Ensure toggle interval is above the minimum
+ miniWidget.value.options.toggleInterval = Math.max(minInterval, miniWidget.value.options.toggleInterval)
setupToggleInterval()
diff --git a/src/components/mini-widgets/MiniVideoRecorder.vue b/src/components/mini-widgets/MiniVideoRecorder.vue
index 5ae65be9c..c551eb266 100644
--- a/src/components/mini-widgets/MiniVideoRecorder.vue
+++ b/src/components/mini-widgets/MiniVideoRecorder.vue
@@ -257,7 +257,7 @@ const updateCurrentStream = async (internalStreamName: string | undefined): Prom
let streamConnectionRoutine: ReturnType | undefined = undefined
-if (widgetStore.isRealMiniWidget(miniWidget.value)) {
+if (widgetStore.isRealMiniWidget(miniWidget.value.hash)) {
streamConnectionRoutine = setInterval(() => {
// If the video recording widget is cold booted, assign the first stream to it
if (miniWidget.value.options.internalStreamName === undefined && !namesAvailableStreams.value.isEmpty()) {
diff --git a/src/stores/widgetManager.ts b/src/stores/widgetManager.ts
index 4624d67c7..6f0220b01 100644
--- a/src/stores/widgetManager.ts
+++ b/src/stores/widgetManager.ts
@@ -69,6 +69,9 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => {
}
const miniWidgetManagerVars = (miniWidgetHash: string): MiniWidgetManagerVars => {
+ if (!isRealMiniWidget(miniWidgetHash)) {
+ return { ...defaultMiniWidgetManagerVars }
+ }
if (!_miniWidgetManagerVars.value[miniWidgetHash]) {
_miniWidgetManagerVars.value[miniWidgetHash] = { ...defaultMiniWidgetManagerVars }
}
@@ -456,17 +459,16 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => {
/**
* States whether the given mini-widget is a real mini-widget
* Fake mini-widgets are those used as placeholders, in the edit-menu, for example
- * @param { MiniWidget } miniWidget - Mini-widget
+ * @param { string } miniWidgetHash - Hash of the mini-widget
* @returns { boolean }
*/
- function isRealMiniWidget(miniWidget: MiniWidget): boolean {
- return savedProfiles.value.some((profile) =>
- profile.views.some((view) =>
- view.miniWidgetContainers.some((container) =>
- container.widgets.some((widget) => widget.hash === miniWidget.hash)
- )
- )
- )
+ function isRealMiniWidget(miniWidgetHash: string): boolean {
+ const allContainers = [
+ ...savedProfiles.value.flatMap((profile) => profile.views.flatMap((view) => view.miniWidgetContainers)),
+ ...currentMiniWidgetsProfile.value.containers,
+ ]
+
+ return allContainers.some((container) => container.widgets.some((widget) => widget.hash === miniWidgetHash))
}
const fullScreenPosition = { x: 0, y: 0 }