Files
Trilium/apps/client/src/widgets/ribbon/EditedNotesTab.tsx

52 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-08-22 17:31:06 +03:00
import { useEffect, useState } from "preact/hooks";
import { TabContext } from "./ribbon-interface";
import { EditedNotesResponse } from "@triliumnext/commons";
import server from "../../services/server";
import { t } from "../../services/i18n";
import froca from "../../services/froca";
import NoteLink from "../react/NoteLink";
import { joinElements } from "../react/react_utils";
2025-08-22 17:31:06 +03:00
export default function EditedNotesTab({ note }: TabContext) {
const [ editedNotes, setEditedNotes ] = useState<EditedNotesResponse>();
useEffect(() => {
if (!note) return;
server.get<EditedNotesResponse>(`edited-notes/${note.getLabelValue("dateNote")}`).then(async editedNotes => {
editedNotes = editedNotes.filter((n) => n.noteId !== note.noteId);
const noteIds = editedNotes.flatMap((n) => n.noteId);
2025-08-22 17:31:06 +03:00
await froca.getNotes(noteIds, true); // preload all at once
setEditedNotes(editedNotes);
});
}, [ note?.noteId ]);
return (
<div className="edited-notes-widget" style={{
padding: "12px",
maxHeight: "200px",
width: "100%",
overflow: "auto"
}}>
{editedNotes?.length ? (
2025-08-22 17:31:06 +03:00
<div className="edited-notes-list use-tn-links">
{joinElements(editedNotes.map(editedNote => {
2025-08-22 17:31:06 +03:00
return (
<span className="edited-note-line">
{editedNote.isDeleted ? (
<i>{`${editedNote.title} ${t("edited_notes.deleted")}`}</i>
) : (
<>
{editedNote.notePath ? <NoteLink notePath={editedNote.notePath} showNotePath /> : <span>{editedNote.title}</span> }
</>
)}
</span>
)
}), " ")}
2025-08-22 17:31:06 +03:00
</div>
) : (
<div className="no-edited-notes-found">{t("edited_notes.no_edited_notes_found")}</div>
)}
</div>
)
2025-08-22 17:31:06 +03:00
}