Skip to content

Build your personal knowledge base with Trilium Notes

client: add a "Deleted Notes" dialog

Adorian Doranf04fc8ddd471
diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts
index c93f0312a3..8142677e2a 100644
--- a/apps/client/src/components/app_context.ts
+++ b/apps/client/src/components/app_context.ts
@@ -142,7 +142,7 @@ export type CommandMappings = {
showPromptDialog: PromptDialogOptions;
showInfoDialog: InfoProps;
showConfirmDialog: ConfirmWithMessageOptions;
- showRecentChanges: CommandData & { ancestorNoteId: string };
+ showRecentChanges: CommandData & { ancestorNoteId?: string; deletedOnly?: boolean };
showImportDialog: CommandData & { noteId: string };
openNewNoteSplit: NoteCommandData;
openInWindow: NoteCommandData;
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 850572400a..cc73fb4ff6 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -417,6 +417,7 @@
},
"recent_changes": {
"title": "Recent changes",
+ "deleted_notes_title": "Deleted notes",
"erase_notes_button": "Erase deleted notes now",
"deleted_notes_message": "Deleted notes have been erased.",
"no_changes_message": "No changes yet...",
@@ -858,6 +859,7 @@
"zoom_in": "Zoom In",
"configure_launchbar": "Configure Launchbar",
"show_shared_notes_subtree": "Show Shared Notes Subtree",
+ "show_deleted_notes": "Show Deleted Notes",
"advanced": "Advanced",
"open_dev_tools": "Open Dev Tools",
"open_sql_console": "Open SQL Console",
diff --git a/apps/client/src/widgets/buttons/global_menu.tsx b/apps/client/src/widgets/buttons/global_menu.tsx
index 711c28d8e2..b95570a25c 100644
--- a/apps/client/src/widgets/buttons/global_menu.tsx
+++ b/apps/client/src/widgets/buttons/global_menu.tsx
@@ -53,6 +53,7 @@ export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout:
<MenuItem command="openNewWindow" icon="bx bx-window-open" text={t("global_menu.open_new_window")} />
<MenuItem command="showShareSubtree" icon="bx bx-share-alt" text={t("global_menu.show_shared_notes_subtree")} />
+ <MenuItem command={() => parentComponent?.triggerCommand("showRecentChanges", { deletedOnly: true })} icon="bx bx-trash" text={t("global_menu.show_deleted_notes")} />
<FormDropdownDivider />
<ZoomControls parentComponent={parentComponent} />
diff --git a/apps/client/src/widgets/dialogs/recent_changes.tsx b/apps/client/src/widgets/dialogs/recent_changes.tsx
index d0c26d2d46..b80a0018b9 100644
--- a/apps/client/src/widgets/dialogs/recent_changes.tsx
+++ b/apps/client/src/widgets/dialogs/recent_changes.tsx
@@ -20,15 +20,17 @@ export default function RecentChangesDialog() {
const [ groupedByDate, setGroupedByDate ] = useState<Map<string, RecentChangeRow[]>>();
const [ refreshCounter, setRefreshCounter ] = useState(0);
const [ shown, setShown ] = useState(false);
+ const [ deletedOnly, setDeletedOnly ] = useState(false);
- useTriliumEvent("showRecentChanges", ({ ancestorNoteId }) => {
+ useTriliumEvent("showRecentChanges", ({ ancestorNoteId, deletedOnly }) => {
setAncestorNoteId(ancestorNoteId ?? hoisted_note.getHoistedNoteId());
+ setDeletedOnly(deletedOnly ?? false);
setShown(true);
});
useEffect(() => {
if (!ancestorNoteId) return;
- server.get<RecentChangeRow[]>(`recent-changes/${ancestorNoteId}`)
+ server.get<RecentChangeRow[]>(`recent-changes/${ancestorNoteId}?deletedOnly=${deletedOnly}`)
.then(async (recentChanges) => {
// preload all notes into cache
await froca.getNotes(
@@ -39,12 +41,12 @@ export default function RecentChangesDialog() {
const groupedByDate = groupByDate(recentChanges);
setGroupedByDate(groupedByDate);
});
- }, [ shown, refreshCounter ])
+ }, [ shown, refreshCounter, deletedOnly ])
return (
<Modal
- title={t("recent_changes.title")}
- className="recent-changes-dialog"
+ title={deletedOnly ? t("recent_changes.deleted_notes_title") : t("recent_changes.title")}
+ className={`recent-changes-dialog ${deletedOnly ? "recent-changes-dialog-view-mode-deleted-only" : "recent-changes-dialog-view-mode-all-changes"}`}
size="lg"
scrollable
header={
diff --git a/packages/trilium-core/src/routes/api/recent_changes.ts b/packages/trilium-core/src/routes/api/recent_changes.ts
index 0ec32da19e..f30d0a4b5c 100644
--- a/packages/trilium-core/src/routes/api/recent_changes.ts
+++ b/packages/trilium-core/src/routes/api/recent_changes.ts
@@ -5,8 +5,9 @@ import type { Request } from "express";
import type { RecentChangeRow } from "@triliumnext/commons";
import { getSql } from "../../services/sql/index.js";
-function getRecentChanges(req: Request<{ ancestorNoteId: string }>) {
+function getRecentChanges(req: Request<{ ancestorNoteId: string }, unknown, unknown, { deletedOnly?: string }>) {
const { ancestorNoteId } = req.params;
+ const deletedOnly = req.query.deletedOnly === "true";
let recentChanges: RecentChangeRow[] = [];
@@ -70,6 +71,10 @@ function getRecentChanges(req: Request<{ ancestorNoteId: string }>) {
}
}
+ if (deletedOnly) {
+ recentChanges = recentChanges.filter((change) => change.current_isDeleted);
+ }
+
recentChanges.sort((a, b) => (a.utcDate > b.utcDate ? -1 : 1));
recentChanges = recentChanges.slice(0, Math.min(500, recentChanges.length));