mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-18 16:32:33 +08:00
feat(time_selector): make use of optionsService
This commit is contained in:
parent
bb4c3ae6ff
commit
ce1f418aa7
@ -2,6 +2,7 @@ import OptionsWidget from "./options_widget.js";
|
|||||||
import toastService from "../../../services/toast.js";
|
import toastService from "../../../services/toast.js";
|
||||||
import { t } from "../../../services/i18n.js";
|
import { t } from "../../../services/i18n.js";
|
||||||
import type { OptionDefinitions, OptionMap } from "../../../../../services/options_interface.js";
|
import type { OptionDefinitions, OptionMap } from "../../../../../services/options_interface.js";
|
||||||
|
import optionsService from "../../../services/options.js";
|
||||||
|
|
||||||
type TimeSelectorConstructor = {
|
type TimeSelectorConstructor = {
|
||||||
widgetId: string;
|
widgetId: string;
|
||||||
@ -93,10 +94,14 @@ export default class TimeSelector extends OptionsWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async optionsLoaded(options: OptionMap) {
|
async optionsLoaded(options: OptionMap) {
|
||||||
this.internalTimeInSeconds = options[this.optionValueId];
|
const optionValue = optionsService.getInt(this.optionValueId) || 0;
|
||||||
const displayedTime = this.convertTime(options[this.optionValueId], options[this.optionTimeScaleId]).toDisplay();
|
const optionTimeScale = optionsService.getInt(this.optionTimeScaleId) || 1;
|
||||||
|
|
||||||
|
this.setInternalTimeInSeconds(optionValue);
|
||||||
|
|
||||||
|
const displayedTime = this.convertTime(optionValue, optionTimeScale).toDisplay();
|
||||||
this.$timeValueInput.val(displayedTime);
|
this.$timeValueInput.val(displayedTime);
|
||||||
this.$timeScaleSelect.val(options[this.optionTimeScaleId]);
|
this.$timeScaleSelect.val(optionTimeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertTime(time: string | number, timeScale: string | number) {
|
private convertTime(time: string | number, timeScale: string | number) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user