From 72c42afb50c5c038c1dc4e7f4119ef2d5ab4d954 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 11 Apr 2026 12:53:36 +0300 Subject: [PATCH] feat(delete): use proper note links and show icons --- .../src/widgets/dialogs/delete_notes.tsx | 68 ++++++------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/apps/client/src/widgets/dialogs/delete_notes.tsx b/apps/client/src/widgets/dialogs/delete_notes.tsx index 59426a44bd..94f1cd0f39 100644 --- a/apps/client/src/widgets/dialogs/delete_notes.tsx +++ b/apps/client/src/widgets/dialogs/delete_notes.tsx @@ -1,18 +1,17 @@ import "./delete_notes.css"; import type { DeleteNotesPreview } from "@triliumnext/commons"; -import { useEffect,useRef, useState } from "preact/hooks"; +import { useEffect, useRef, useState } from "preact/hooks"; -import FNote from "../../entities/fnote.js"; import froca from "../../services/froca.js"; import { t } from "../../services/i18n.js"; -import link from "../../services/link.js"; import server from "../../services/server.js"; import Button from "../react/Button.jsx"; import { Card, CardSection } from "../react/Card.js"; import FormToggle from "../react/FormToggle.js"; import { useTriliumEvent } from "../react/hooks.jsx"; import Modal from "../react/Modal.js"; +import NoteLink from "../react/NoteLink.js"; import OptionsRow from "../type_widgets/options/components/OptionsRow.js"; interface CloneInfo { @@ -32,9 +31,9 @@ interface ShowDeleteNotesDialogOpts { } interface BrokenRelationData { - note: string; - relation: string; - source: string; + noteId: string; + relationName: string; + sourceNoteId: string; } export default function DeleteNotesDialog() { @@ -183,27 +182,15 @@ function DeleteAllClonesOption({ cloneInfo, deleteAllClones, setDeleteAllClones } function DeletedNotes({ noteIdsToBeDeleted }: { noteIdsToBeDeleted: DeleteNotesPreview["noteIdsToBeDeleted"] }) { - const [ noteLinks, setNoteLinks ] = useState([]); - - useEffect(() => { - froca.getNotes(noteIdsToBeDeleted).then(async (notes: FNote[]) => { - const noteLinks: string[] = []; - - for (const note of notes) { - noteLinks.push((await link.createLink(note.noteId, { showNotePath: true })).html()); - } - - setNoteLinks(noteLinks); - }); - }, [noteIdsToBeDeleted]); - return ( {noteIdsToBeDeleted.length ? (
    - {noteLinks.map((link, index) => ( -
  • + {noteIdsToBeDeleted.map((noteId) => ( +
  • + +
  • ))}
) : ( @@ -215,34 +202,23 @@ function DeletedNotes({ noteIdsToBeDeleted }: { noteIdsToBeDeleted: DeleteNotesP } function BrokenRelations({ brokenRelations }: { brokenRelations: DeleteNotesPreview["brokenRelations"] }) { - const [ notesWithBrokenRelations, setNotesWithBrokenRelations ] = useState([]); - - useEffect(() => { - const noteIds = brokenRelations - .map(relation => relation.noteId) - .filter(noteId => noteId) as string[]; - froca.getNotes(noteIds).then(async () => { - const notesWithBrokenRelations: BrokenRelationData[] = []; - for (const attr of brokenRelations) { - notesWithBrokenRelations.push({ - note: (await link.createLink(attr.value)).html(), - relation: `${attr.name}`, - source: (await link.createLink(attr.noteId)).html() - }); - } - setNotesWithBrokenRelations(notesWithBrokenRelations); - }); - }, [brokenRelations]); - if (!brokenRelations.length) { return null; } + const relationsData: BrokenRelationData[] = brokenRelations + .filter((attr) => attr.value && attr.noteId) + .map((attr) => ({ + noteId: attr.value!, + relationName: attr.name, + sourceNoteId: attr.noteId! + })); + return (
- +
@@ -251,11 +227,11 @@ function BrokenRelations({ brokenRelations }: { brokenRelations: DeleteNotesPrev - {notesWithBrokenRelations.map((relation, index) => ( + {relationsData.map((relation, index) => ( - + + ))}
{t("delete_notes.table_note")}
- - + {relation.relationName}