Skip to content

Commit ec76e9c

Browse files
committed
refactor(collections): fix typecheck and remove generics
1 parent 88ae996 commit ec76e9c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

apps/client/src/print.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import FNote from "./entities/fnote";
22
import { render } from "preact";
3-
import { CustomNoteList } from "./widgets/collections/NoteList";
3+
import { CustomNoteList, useNoteViewType } from "./widgets/collections/NoteList";
44
import { useCallback, useLayoutEffect, useRef } from "preact/hooks";
55
import content_renderer from "./services/content_renderer";
66

@@ -85,7 +85,9 @@ function SingleNoteRenderer({ note, onReady }: RendererProps) {
8585
}
8686

8787
function CollectionRenderer({ note, onReady }: RendererProps) {
88+
const viewType = useNoteViewType(note);
8889
return <CustomNoteList
90+
viewType={viewType}
8991
isEnabled
9092
note={note}
9193
notePath={note.getBestNotePath().join("/")}

apps/client/src/widgets/collections/NoteList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface NoteListProps {
2727
onReady?: () => void;
2828
}
2929

30-
export default function NoteList<T extends object>(props: Pick<NoteListProps, "displayOnlyCollections" | "media" | "onReady">) {
30+
export default function NoteList(props: Pick<NoteListProps, "displayOnlyCollections" | "media" | "onReady">) {
3131
const { note, noteContext, notePath, ntxId } = useNoteContext();
3232
const viewType = useNoteViewType(note);
3333
const [ enabled, setEnabled ] = useState(noteContext?.hasNoteList());
@@ -37,12 +37,12 @@ export default function NoteList<T extends object>(props: Pick<NoteListProps, "d
3737
return <CustomNoteList viewType={viewType} note={note} isEnabled={!!enabled} notePath={notePath} ntxId={ntxId} {...props} />
3838
}
3939

40-
export function SearchNoteList<T extends object>(props: Omit<NoteListProps, "isEnabled">) {
40+
export function SearchNoteList(props: Omit<NoteListProps, "isEnabled" | "viewType">) {
4141
const viewType = useNoteViewType(props.note);
4242
return <CustomNoteList {...props} isEnabled={true} viewType={viewType} />
4343
}
4444

45-
export function CustomNoteList<T extends object>({ note, viewType, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections, ntxId, onReady, ...restProps }: NoteListProps) {
45+
export function CustomNoteList({ note, viewType, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections, ntxId, onReady, ...restProps }: NoteListProps) {
4646
const widgetRef = useRef<HTMLDivElement>(null);
4747
const noteIds = useNoteIds(shouldEnable ? note : null, viewType, ntxId);
4848
const isFullHeight = (viewType && viewType !== "list" && viewType !== "grid");
@@ -119,7 +119,7 @@ function getComponentByViewType(viewType: ViewTypeOptions, props: ViewModeProps<
119119
}
120120
}
121121

122-
function useNoteViewType(note?: FNote | null): ViewTypeOptions | undefined {
122+
export function useNoteViewType(note?: FNote | null): ViewTypeOptions | undefined {
123123
const [ viewType ] = useNoteLabel(note, "viewType");
124124

125125
if (!note) {

0 commit comments

Comments
 (0)