import { formatDateTime } from "../../utils/formatters.js"; import { t } from "../../services/i18n.js"; import appContext from "../../components/app_context.js"; import BasicWidget from "../basic_widget.js"; import dialogService from "../../services/dialog.js"; import froca from "../../services/froca.js"; import hoistedNoteService from "../../services/hoisted_note.js"; import linkService from "../../services/link.js"; import server from "../../services/server.js"; import toastService from "../../services/toast.js"; import utils from "../../services/utils.js"; import ws from "../../services/ws.js"; import { Modal } from "bootstrap"; const TPL = ` `; export default class RecentChangesDialog extends BasicWidget { doRender() { this.$widget = $(TPL); this.modal = Modal.getOrCreateInstance(this.$widget); this.$content = this.$widget.find(".recent-changes-content"); this.$eraseDeletedNotesNow = this.$widget.find(".erase-deleted-notes-now-button"); this.$eraseDeletedNotesNow.on("click", () => { server.post("notes/erase-deleted-notes-now").then(() => { this.refresh(); toastService.showMessage(t("recent_changes.deleted_notes_message")); }); }); } async showRecentChangesEvent({ ancestorNoteId }) { this.ancestorNoteId = ancestorNoteId; await this.refresh(); utils.openDialog(this.$widget); } async refresh() { if (!this.ancestorNoteId) { this.ancestorNoteId = hoistedNoteService.getHoistedNoteId(); } const recentChangesRows = await server.get(`recent-changes/${this.ancestorNoteId}`); // preload all notes into cache await froca.getNotes( recentChangesRows.map((r) => r.noteId), true ); this.$content.empty(); if (recentChangesRows.length === 0) { this.$content.append(t("recent_changes.no_changes_message")); } const groupedByDate = this.groupByDate(recentChangesRows); for (const [dateDay, dayChanges] of groupedByDate) { const $changesList = $("