diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx index 63eb64a99..d458cb68b 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 { - 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; + isEnabled: boolean; } -export default function NoteList({ note: providedNote, highlightedTokens, displayOnlyCollections }: NoteListProps) { +export default function NoteList(props: Pick, "displayOnlyCollections">) { + const { note, noteContext, notePath } = useNoteContext(); + const isEnabled = noteContext?.hasNoteList(); + return +} + +export function SearchNoteList(props: Omit, "isEnabled">) { + return +} + +function CustomNoteList({ note, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections }: NoteListProps) { const widgetRef = useRef(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 abe9d4174..c259e2cb7 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(); const [ highlightedTokens, setHighlightedTokens ] = useState(); @@ -53,7 +53,11 @@ export default function SearchResult() { )} {state === SearchResultState.GOT_RESULTS && ( - + )} );