Skip to content

Build your personal knowledge base with Trilium Notes

fix(client/search): results not being displayed

Elian Dorand2962b060e5f
diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx
index 63eb64a993..d458cb68b9 100644
--- a/apps/client/src/widgets/collections/NoteList.tsx
+++ b/apps/client/src/widgets/collections/NoteList.tsx
@@ -14,23 +14,32 @@ import { WebSocketMessage } from "@triliumnext/commons";
import froca from "../../services/froca";
interface NoteListProps<T extends object> {
- note?: FNote | null;
+ note: FNote | null | undefined;
+ notePath: string | null | undefined;
+ highlightedTokens?: string[] | null;
/** if set to `true` then only collection-type views are displayed such as geo-map and the calendar. The original book types grid and list will be ignored. */
displayOnlyCollections?: boolean;
- highlightedTokens?: string[] | null;
- viewStorage?: ViewModeStorage<T>;
+ isEnabled: boolean;
+}
+
+export default function NoteList<T extends object>(props: Pick<NoteListProps<T>, "displayOnlyCollections">) {
+ const { note, noteContext, notePath } = useNoteContext();
+ const isEnabled = noteContext?.hasNoteList();
+ return <CustomNoteList note={note} isEnabled={!!isEnabled} notePath={notePath} {...props} />
+}
+
+export function SearchNoteList<T extends object>(props: Omit<NoteListProps<T>, "isEnabled">) {
+ return <CustomNoteList {...props} isEnabled={true} />
}
-export default function NoteList<T extends object>({ note: providedNote, highlightedTokens, displayOnlyCollections }: NoteListProps<T>) {
+function CustomNoteList<T extends object>({ note, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections }: NoteListProps<T>) {
const widgetRef = useRef<HTMLDivElement>(null);
- const { note: contextNote, noteContext, notePath } = useNoteContext();
- const note = providedNote ?? contextNote;
const viewType = useNoteViewType(note);
const noteIds = useNoteIds(note, viewType);
const isFullHeight = (viewType && viewType !== "list" && viewType !== "grid");
const [ isIntersecting, setIsIntersecting ] = useState(false);
const shouldRender = (isFullHeight || isIntersecting || note?.type === "book");
- const isEnabled = (note && noteContext?.hasNoteList() && !!viewType && shouldRender);
+ const isEnabled = (note && shouldEnable && !!viewType && shouldRender);
useEffect(() => {
if (isFullHeight || displayOnlyCollections || note?.type === "book") {
diff --git a/apps/client/src/widgets/search_result.tsx b/apps/client/src/widgets/search_result.tsx
index abe9d4174f..c259e2cb7c 100644
--- a/apps/client/src/widgets/search_result.tsx
+++ b/apps/client/src/widgets/search_result.tsx
@@ -3,7 +3,7 @@ import { t } from "../services/i18n";
import Alert from "./react/Alert";
import { useNoteContext, useTriliumEvent } from "./react/hooks";
import "./search_result.css";
-import NoteList from "./collections/NoteList";
+import { SearchNoteList } from "./collections/NoteList";
// import NoteListRenderer from "../services/note_list_renderer";
enum SearchResultState {
@@ -13,7 +13,7 @@ enum SearchResultState {
}
export default function SearchResult() {
- const { note, ntxId } = useNoteContext();
+ const { note, notePath, ntxId } = useNoteContext();
const [ state, setState ] = useState<SearchResultState>();
const [ highlightedTokens, setHighlightedTokens ] = useState<string[]>();
@@ -53,7 +53,11 @@ export default function SearchResult() {
)}
{state === SearchResultState.GOT_RESULTS && (
- <NoteList note={note} highlightedTokens={highlightedTokens} />
+ <SearchNoteList
+ note={note}
+ notePath={notePath}
+ highlightedTokens={highlightedTokens}
+ />
)}
</div>
);