feat(react/settings): port note revision snapshot interval

This commit is contained in:
Elian Doran
2025-08-18 17:51:45 +03:00
parent a71d28500d
commit c5a7f84250
9 changed files with 1659 additions and 1669 deletions

View File

@@ -1,3 +1,4 @@
import { Trans } from "react-i18next";
import { t } from "../../../services/i18n";
import server from "../../../services/server";
import toast from "../../../services/toast";
@@ -11,6 +12,7 @@ export default function OtherSettings() {
<>
<NoteErasureTimeout />
<AttachmentErasureTimeout />
<RevisionSnapshotInterval />
</>
)
}
@@ -59,4 +61,23 @@ function AttachmentErasureTimeout() {
/>
</OptionsSection>
)
}
function RevisionSnapshotInterval() {
return (
<OptionsSection title={t("revisions_snapshot_interval.note_revisions_snapshot_interval_title")}>
<FormText>
<Trans
i18nKey="revisions_snapshot_interval.note_revisions_snapshot_description"
components={{ doc: <a href="https://triliumnext.github.io/Docs/Wiki/note-revisions.html" class="external" />}}
/>
</FormText>
<TimeSelector
name="revision-snapshot-time-interval"
label={t("revisions_snapshot_interval.snapshot_time_interval_label")}
optionValueId="revisionSnapshotTimeInterval" optionTimeScaleId="revisionSnapshotTimeIntervalTimeScale"
minimumSeconds={10}
/>
</OptionsSection>
)
}

View File

@@ -1,31 +0,0 @@
import { t } from "../../../../services/i18n.js";
import TimeSelector from "../time_selector.js";
const TPL = /*html*/`
<div class="options-section">
<h4>${t("revisions_snapshot_interval.note_revisions_snapshot_interval_title")}</h4>
<p class="form-text use-tn-links">${t("revisions_snapshot_interval.note_revisions_snapshot_description")}</p>
<div id="time-selector-placeholder"></div>
</div>`;
export default class RevisionsSnapshotIntervalOptions extends TimeSelector {
constructor() {
super({
widgetId: "revision-snapshot-time-interval",
widgetLabelId: "revisions_snapshot_interval.snapshot_time_interval_label",
optionValueId: "revisionSnapshotTimeInterval",
optionTimeScaleId: "revisionSnapshotTimeIntervalTimeScale",
minimumSeconds: 10
});
super.doRender();
}
doRender() {
const $timeSelector = this.$widget;
// inject TimeSelector widget template
this.$widget = $(TPL);
this.$widget.find("#time-selector-placeholder").replaceWith($timeSelector);
}
}