From ce1f418aa72a443a1a546e437c5e4832a0d6d3c8 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 18 Feb 2025 22:18:58 +0100 Subject: [PATCH] feat(time_selector): make use of optionsService --- .../app/widgets/type_widgets/options/time_selector.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/public/app/widgets/type_widgets/options/time_selector.ts b/src/public/app/widgets/type_widgets/options/time_selector.ts index 705cc7f75..94f607b99 100644 --- a/src/public/app/widgets/type_widgets/options/time_selector.ts +++ b/src/public/app/widgets/type_widgets/options/time_selector.ts @@ -2,6 +2,7 @@ import OptionsWidget from "./options_widget.js"; import toastService from "../../../services/toast.js"; import { t } from "../../../services/i18n.js"; import type { OptionDefinitions, OptionMap } from "../../../../../services/options_interface.js"; +import optionsService from "../../../services/options.js"; type TimeSelectorConstructor = { widgetId: string; @@ -93,10 +94,14 @@ export default class TimeSelector extends OptionsWidget { } async optionsLoaded(options: OptionMap) { - this.internalTimeInSeconds = options[this.optionValueId]; - const displayedTime = this.convertTime(options[this.optionValueId], options[this.optionTimeScaleId]).toDisplay(); + const optionValue = optionsService.getInt(this.optionValueId) || 0; + const optionTimeScale = optionsService.getInt(this.optionTimeScaleId) || 1; + + this.setInternalTimeInSeconds(optionValue); + + const displayedTime = this.convertTime(optionValue, optionTimeScale).toDisplay(); this.$timeValueInput.val(displayedTime); - this.$timeScaleSelect.val(options[this.optionTimeScaleId]); + this.$timeScaleSelect.val(optionTimeScale); } private convertTime(time: string | number, timeScale: string | number) {