Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(prettier): run prettier on time_selector related files
Panagiotis Papadopoulos10ba46720202
diff --git a/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.ts b/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.tsindex c384dce107..65cd61ce6f 100644--- a/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.ts+++ b/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.ts@@ -18,7 +18,6 @@ const TPL2 = `</div>`;export default class AttachmentErasureTimeoutOptions extends TimeSelector {-private $eraseUnusedAttachmentsNowButton!: JQuery<HTMLElement>;constructor() {@@ -27,8 +26,8 @@ export default class AttachmentErasureTimeoutOptions extends TimeSelector {widgetLabelId: "attachment_erasure_timeout.erase_attachments_after_x_seconds",optionValueId: "eraseUnusedAttachmentsAfterSeconds",optionTimeScaleId: "eraseUnusedAttachmentsAfterTimeScale"- })- super.doRender()+ });+ super.doRender();}doRender() {@@ -41,5 +40,4 @@ export default class AttachmentErasureTimeoutOptions extends TimeSelector {});});}-}diff --git a/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.ts b/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.tsindex f06274c03a..d71a2c3705 100644--- a/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.ts+++ b/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.ts@@ -17,22 +17,19 @@ const TPL2 = `</div>`;export default class NoteErasureTimeoutOptions extends TimeSelector {-private $eraseDeletedNotesButton!: JQuery<HTMLButtonElement>;constructor() {- super( {+ super({widgetId: "erase-entities-after",widgetLabelId: "note_erasure_timeout.erase_notes_after",optionValueId: "eraseEntitiesAfterTimeInSeconds",optionTimeScaleId: "eraseEntitiesAfterTimeScale"- })+ });super.doRender();-}doRender() {-this.$widget = $(TPL).append(this.$widget).append(TPL2);this.$eraseDeletedNotesButton = this.$widget.find("#erase-deleted-notes-now-button");@@ -43,5 +40,4 @@ export default class NoteErasureTimeoutOptions extends TimeSelector {});});}-}diff --git a/src/public/app/widgets/type_widgets/options/time_selector.ts b/src/public/app/widgets/type_widgets/options/time_selector.tsindex 1bd4130227..dc95b0a771 100644--- a/src/public/app/widgets/type_widgets/options/time_selector.ts+++ b/src/public/app/widgets/type_widgets/options/time_selector.ts@@ -3,7 +3,6 @@ import toastService from "../../../services/toast.js";import { t } from "../../../services/i18n.js";import type { OptionDefinitions, OptionMap } from "../../../../../services/options_interface.js";-type TimeSelectorConstructor = {widgetId: string;widgetLabelId: string;@@ -14,7 +13,6 @@ type TimeSelectorConstructor = {type TimeSelectorScale = "seconds" | "minutes" | "hours" | "days";-const TPL = (options: Omit<TimeSelectorConstructor, "optionValueId" | "optionTimeScaleId">) => `<div class="form-group"><label for="${options.widgetId}">${t(options.widgetLabelId)}</label>@@ -37,7 +35,6 @@ const TPL = (options: Omit<TimeSelectorConstructor, "optionValueId" | "optionTim</style>`;export default class TimeSelector extends OptionsWidget {-private $timeValueInput!: JQuery<HTMLInputElement>;private $timeScaleSelect!: JQuery<HTMLSelectElement>;private internalTimeInSeconds!: string | number;@@ -53,15 +50,17 @@ export default class TimeSelector extends OptionsWidget {this.widgetLabelId = options.widgetLabelId;this.optionValueId = options.optionValueId;this.optionTimeScaleId = options.optionTimeScaleId;- this.includedTimeScales = (!options.includedTimeScales) ? new Set(["seconds", "minutes", "hours", "days"]) : options.includedTimeScales;+ this.includedTimeScales = !options.includedTimeScales ? new Set(["seconds", "minutes", "hours", "days"]) : options.includedTimeScales;}doRender() {- this.$widget = $(TPL({- widgetId: this.widgetId,- widgetLabelId: this.widgetLabelId,- includedTimeScales: this.includedTimeScales,- }));+ this.$widget = $(+ TPL({+ widgetId: this.widgetId,+ widgetLabelId: this.widgetLabelId,+ includedTimeScales: this.includedTimeScales+ })+ );this.$timeValueInput = this.$widget.find(`#${this.widgetId}`);this.$timeScaleSelect = this.$widget.find(`#${this.widgetId}-time-scale`);@@ -74,11 +73,9 @@ export default class TimeSelector extends OptionsWidget {this.internalTimeInSeconds = this.convertTime(time, timeScale).toOption();this.updateOption(this.optionValueId, this.internalTimeInSeconds);-});this.$timeScaleSelect.on("change", () => {-const timeScale = this.$timeScaleSelect.val();if (!this.handleTimeValidation() || typeof timeScale !== "string") return;@@ -88,9 +85,7 @@ export default class TimeSelector extends OptionsWidget {this.updateOption(this.optionTimeScaleId, timeScale);this.$timeValueInput.val(displayedTime).trigger("change");-});-}async optionsLoaded(options: OptionMap) {@@ -100,12 +95,10 @@ export default class TimeSelector extends OptionsWidget {this.$timeScaleSelect.val(options[this.optionTimeScaleId]);}-convertTime(time: string | number, timeScale: string | number) {-const value = typeof time === "number" ? time : parseInt(time);if (Number.isNaN(value)) {- throw new Error(`Time needs to be a valid integer, but received: ${time}`);+ throw new Error(`Time needs to be a valid integer, but received: ${time}`);}const operand = typeof timeScale === "number" ? timeScale : parseInt(timeScale);@@ -115,17 +108,15 @@ export default class TimeSelector extends OptionsWidget {return {toOption: () => Math.ceil(value * operand),- toDisplay: () => Math.ceil(value / operand),- }-+ toDisplay: () => Math.ceil(value / operand)+ };}handleTimeValidation() {if (this.$timeValueInput.is(":invalid")) {toastService.showMessage(t("time_selector.invalid_input"));- return false+ return false;}return true;}--}\ No newline at end of file+}