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
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") {