Skip to content

Build your personal knowledge base with Trilium Notes

chore(search): reuse search command

Elian Dorand245fdd1b8ac
diff --git a/apps/client/src/widgets/search_result.tsx b/apps/client/src/widgets/search_result.tsx
index 57e45b6930..cb32f8b8b7 100644
--- a/apps/client/src/widgets/search_result.tsx
+++ b/apps/client/src/widgets/search_result.tsx
@@ -3,10 +3,7 @@ import "./search_result.css";
import clsx from "clsx";
import { useEffect, useState } from "preact/hooks";
-import froca from "../services/froca";
import { t } from "../services/i18n";
-import toast from "../services/toast";
-import { getErrorMessage } from "../services/utils";
import { SearchNoteList } from "./collections/NoteList";
import Button from "./react/Button";
import { useNoteContext, useTriliumEvent } from "./react/hooks";
@@ -19,7 +16,7 @@ enum SearchResultState {
}
export default function SearchResult() {
- const { note, notePath, ntxId, parentComponent } = useNoteContext();
+ const { note, notePath, ntxId } = useNoteContext();
const [ state, setState ] = useState<SearchResultState>();
const [ highlightedTokens, setHighlightedTokens ] = useState<string[]>();
@@ -54,19 +51,7 @@ export default function SearchResult() {
<NoItems icon="bx bx-file-find" text={t("search_result.search_not_executed")}>
<Button
text="Search now"
- onClick={async () => {
- if (!note) return;
- try {
- const result = await froca.loadSearchNote(note.noteId);
- if (result?.error) {
- toast.showError(result.error);
- }
-
- parentComponent?.triggerEvent("searchRefreshed", { ntxId });
- } catch (e) {
- toast.showError(getErrorMessage(e));
- }
- }}
+ triggerCommand="searchNotes"
/>
</NoItems>
)}