mirror of
https://github.com/zadam/trilium.git
synced 2025-11-21 16:14:23 +01:00
fix(collections): view type not refreshing properly
This commit is contained in:
parent
d1d1d05ce7
commit
88ae996694
@ -23,22 +23,27 @@ interface NoteListProps {
|
|||||||
isEnabled: boolean;
|
isEnabled: boolean;
|
||||||
ntxId: string | null | undefined;
|
ntxId: string | null | undefined;
|
||||||
media: ViewModeMedia;
|
media: ViewModeMedia;
|
||||||
|
viewType: ViewTypeOptions | undefined;
|
||||||
onReady?: () => void;
|
onReady?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function NoteList<T extends object>(props: Pick<NoteListProps, "displayOnlyCollections" | "media" | "onReady">) {
|
export default function NoteList<T extends object>(props: Pick<NoteListProps, "displayOnlyCollections" | "media" | "onReady">) {
|
||||||
const { note, noteContext, notePath, ntxId } = useNoteContext();
|
const { note, noteContext, notePath, ntxId } = useNoteContext();
|
||||||
const isEnabled = noteContext?.hasNoteList();
|
const viewType = useNoteViewType(note);
|
||||||
return <CustomNoteList note={note} isEnabled={!!isEnabled} notePath={notePath} ntxId={ntxId} {...props} />
|
const [ enabled, setEnabled ] = useState(noteContext?.hasNoteList());
|
||||||
|
useEffect(() => {
|
||||||
|
setEnabled(noteContext?.hasNoteList());
|
||||||
|
}, [ noteContext, viewType ])
|
||||||
|
return <CustomNoteList viewType={viewType} note={note} isEnabled={!!enabled} notePath={notePath} ntxId={ntxId} {...props} />
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SearchNoteList<T extends object>(props: Omit<NoteListProps, "isEnabled">) {
|
export function SearchNoteList<T extends object>(props: Omit<NoteListProps, "isEnabled">) {
|
||||||
return <CustomNoteList {...props} isEnabled={true} />
|
const viewType = useNoteViewType(props.note);
|
||||||
|
return <CustomNoteList {...props} isEnabled={true} viewType={viewType} />
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CustomNoteList<T extends object>({ note, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections, ntxId, onReady, ...restProps }: NoteListProps) {
|
export function CustomNoteList<T extends object>({ note, viewType, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections, ntxId, onReady, ...restProps }: NoteListProps) {
|
||||||
const widgetRef = useRef<HTMLDivElement>(null);
|
const widgetRef = useRef<HTMLDivElement>(null);
|
||||||
const viewType = useNoteViewType(note);
|
|
||||||
const noteIds = useNoteIds(shouldEnable ? note : null, viewType, ntxId);
|
const noteIds = useNoteIds(shouldEnable ? note : null, viewType, ntxId);
|
||||||
const isFullHeight = (viewType && viewType !== "list" && viewType !== "grid");
|
const isFullHeight = (viewType && viewType !== "list" && viewType !== "grid");
|
||||||
const [ isIntersecting, setIsIntersecting ] = useState(false);
|
const [ isIntersecting, setIsIntersecting ] = useState(false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user