mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 09:39:00 +01:00
fix(client/search): results not being displayed
This commit is contained in:
parent
fae66e555e
commit
d2962b060e
@ -14,23 +14,32 @@ import { WebSocketMessage } from "@triliumnext/commons";
|
|||||||
import froca from "../../services/froca";
|
import froca from "../../services/froca";
|
||||||
|
|
||||||
interface NoteListProps<T extends object> {
|
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. */
|
/** 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;
|
displayOnlyCollections?: boolean;
|
||||||
highlightedTokens?: string[] | null;
|
isEnabled: boolean;
|
||||||
viewStorage?: ViewModeStorage<T>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 widgetRef = useRef<HTMLDivElement>(null);
|
||||||
const { note: contextNote, noteContext, notePath } = useNoteContext();
|
|
||||||
const note = providedNote ?? contextNote;
|
|
||||||
const viewType = useNoteViewType(note);
|
const viewType = useNoteViewType(note);
|
||||||
const noteIds = useNoteIds(note, viewType);
|
const noteIds = useNoteIds(note, viewType);
|
||||||
const isFullHeight = (viewType && viewType !== "list" && viewType !== "grid");
|
const isFullHeight = (viewType && viewType !== "list" && viewType !== "grid");
|
||||||
const [ isIntersecting, setIsIntersecting ] = useState(false);
|
const [ isIntersecting, setIsIntersecting ] = useState(false);
|
||||||
const shouldRender = (isFullHeight || isIntersecting || note?.type === "book");
|
const shouldRender = (isFullHeight || isIntersecting || note?.type === "book");
|
||||||
const isEnabled = (note && noteContext?.hasNoteList() && !!viewType && shouldRender);
|
const isEnabled = (note && shouldEnable && !!viewType && shouldRender);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isFullHeight || displayOnlyCollections || note?.type === "book") {
|
if (isFullHeight || displayOnlyCollections || note?.type === "book") {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { t } from "../services/i18n";
|
|||||||
import Alert from "./react/Alert";
|
import Alert from "./react/Alert";
|
||||||
import { useNoteContext, useTriliumEvent } from "./react/hooks";
|
import { useNoteContext, useTriliumEvent } from "./react/hooks";
|
||||||
import "./search_result.css";
|
import "./search_result.css";
|
||||||
import NoteList from "./collections/NoteList";
|
import { SearchNoteList } from "./collections/NoteList";
|
||||||
// import NoteListRenderer from "../services/note_list_renderer";
|
// import NoteListRenderer from "../services/note_list_renderer";
|
||||||
|
|
||||||
enum SearchResultState {
|
enum SearchResultState {
|
||||||
@ -13,7 +13,7 @@ enum SearchResultState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function SearchResult() {
|
export default function SearchResult() {
|
||||||
const { note, ntxId } = useNoteContext();
|
const { note, notePath, ntxId } = useNoteContext();
|
||||||
const [ state, setState ] = useState<SearchResultState>();
|
const [ state, setState ] = useState<SearchResultState>();
|
||||||
const [ highlightedTokens, setHighlightedTokens ] = useState<string[]>();
|
const [ highlightedTokens, setHighlightedTokens ] = useState<string[]>();
|
||||||
|
|
||||||
@ -53,7 +53,11 @@ export default function SearchResult() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{state === SearchResultState.GOT_RESULTS && (
|
{state === SearchResultState.GOT_RESULTS && (
|
||||||
<NoteList note={note} highlightedTokens={highlightedTokens} />
|
<SearchNoteList
|
||||||
|
note={note}
|
||||||
|
notePath={notePath}
|
||||||
|
highlightedTokens={highlightedTokens}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user