fix(client/search): results not being displayed

This commit is contained in:
Elian Doran 2025-09-23 21:44:39 +03:00
parent fae66e555e
commit d2962b060e
No known key found for this signature in database
2 changed files with 23 additions and 10 deletions

View File

@ -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>({ note: providedNote, highlightedTokens, displayOnlyCollections }: NoteListProps<T>) {
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} />
}
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") {

View File

@ -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>
);