add "erase all deleted notes now" also to recent changes

This commit is contained in:
zadam 2022-11-17 23:12:36 +01:00
parent d9dac00a01
commit d388b4d814

View file

@ -7,6 +7,7 @@ import appContext from "../../services/app_context.js";
import hoistedNoteService from "../../services/hoisted_note.js";
import BasicWidget from "../basic_widget.js";
import dialogService from "../dialog.js";
import toastService from "../../services/toast.js";
const TPL = `
<div class="recent-changes-dialog modal fade mx-auto" tabindex="-1" role="dialog">
@ -14,7 +15,11 @@ const TPL = `
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Recent changes</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button class="erase-deleted-notes-now-button btn btn-xs" style="padding: 0 10px">
Erase deleted notes now</button>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="margin-left: 0 !important;">
<span aria-hidden="true">&times;</span>
</button>
</div>
@ -29,20 +34,30 @@ export default class RecentChangesDialog extends BasicWidget {
doRender() {
this.$widget = $(TPL);
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("Deleted notes have been erased.");
});
});
}
async showRecentChangesEvent({ancestorNoteId}) {
await this.refresh(ancestorNoteId);
this.ancestorNoteId = ancestorNoteId;
await this.refresh();
utils.openDialog(this.$widget);
}
async refresh(ancestorNoteId) {
if (!ancestorNoteId) {
ancestorNoteId = hoistedNoteService.getHoistedNoteId();
async refresh() {
if (!this.ancestorNoteId) {
this.ancestorNoteId = hoistedNoteService.getHoistedNoteId();
}
const recentChangesRows = await server.get('recent-changes/' + ancestorNoteId);
const recentChangesRows = await server.get('recent-changes/' + this.ancestorNoteId);
// preload all notes into cache
await froca.getNotes(recentChangesRows.map(r => r.noteId), true);