import { useEffect, useState } from "preact/hooks"; import { TabContext } from "./ribbon-interface"; import { SimilarNoteResponse } from "@triliumnext/commons"; import server from "../../services/server"; import { t } from "../../services/i18n"; import froca from "../../services/froca"; import NoteLink from "../react/NoteLink"; export default function SimilarNotesTab({ note }: TabContext) { const [ similarNotes, setSimilarNotes ] = useState(); useEffect(() => { if (note) { server.get(`similar-notes/${note.noteId}`).then(async similarNotes => { if (similarNotes) { const noteIds = similarNotes.flatMap((note) => note.notePath); await froca.getNotes(noteIds, true); // preload all at once } setSimilarNotes(similarNotes); }); } }, [ note?.noteId ]); return (
{similarNotes?.length ? (
{similarNotes.map(({notePath, score}) => ( ))}
) : ( <>{t("similar_notes.no_similar_notes_found")} )}
) }