mirror of
https://github.com/zadam/trilium.git
synced 2026-02-26 16:43:36 +01:00
chore(search): reuse search command
This commit is contained in:
parent
e9c9b456e0
commit
d245fdd1b8
@ -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>
|
||||
)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user