diff --git a/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx b/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx index fc1b45692b..d857b96d06 100644 --- a/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx +++ b/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx @@ -8,7 +8,7 @@ import content_renderer from "../../../services/content_renderer"; import { t } from "../../../services/i18n"; import link from "../../../services/link"; import tree from "../../../services/tree"; -import { useImperativeSearchHighlighlighting, useNoteLabel } from "../../react/hooks"; +import { useImperativeSearchHighlighlighting, useNoteLabel, useNoteLabelBoolean } from "../../react/hooks"; import Icon from "../../react/Icon"; import NoteLink from "../../react/NoteLink"; import { ViewModeProps } from "../interface"; @@ -19,6 +19,7 @@ export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens } const expandDepth = useExpansionDepth(note); const noteIds = useFilteredNoteIds(note, unfilteredNoteIds); const { pageNotes, ...pagination } = usePagination(note, noteIds); + const [ includeArchived ] = useNoteLabelBoolean(note, "includeArchived"); return (
@@ -27,7 +28,11 @@ export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens } @@ -58,12 +63,13 @@ export function GridView({ note, noteIds: unfilteredNoteIds, highlightedTokens } ); } -function ListNoteCard({ note, parentNote, highlightedTokens, currentLevel, expandDepth }: { +function ListNoteCard({ note, parentNote, highlightedTokens, currentLevel, expandDepth, includeArchived }: { note: FNote, parentNote: FNote, currentLevel: number, expandDepth: number, - highlightedTokens: string[] | null | undefined + highlightedTokens: string[] | null | undefined; + includeArchived: boolean; }) { const [ isExpanded, setExpanded ] = useState(currentLevel <= expandDepth); @@ -90,7 +96,7 @@ function ListNoteCard({ note, parentNote, highlightedTokens, currentLevel, expan {isExpanded && <> - + }
); @@ -169,24 +175,26 @@ function NoteContent({ note, trim, noChildrenList, highlightedTokens }: { note: return
; } -function NoteChildren({ note, parentNote, highlightedTokens, currentLevel, expandDepth }: { +function NoteChildren({ note, parentNote, highlightedTokens, currentLevel, expandDepth, includeArchived }: { note: FNote, parentNote: FNote, currentLevel: number, expandDepth: number, highlightedTokens: string[] | null | undefined + includeArchived: boolean; }) { const [ childNotes, setChildNotes ] = useState(); useEffect(() => { - filterChildNotes(note).then(setChildNotes); - }, [ note ]); + filterChildNotes(note, includeArchived).then(setChildNotes); + }, [ note, includeArchived ]); return childNotes?.map(childNote => ); } @@ -194,9 +202,9 @@ function getNotePath(parentNote: FNote, childNote: FNote) { if (parentNote.type === "search") { // for search note parent, we want to display a non-search path return childNote.noteId; - } + } return `${parentNote.noteId}/${childNote.noteId}`; - + } function useExpansionDepth(note: FNote) { @@ -208,7 +216,7 @@ function useExpansionDepth(note: FNote) { return 1; } else if (expandDepth === "all") { return Number.MAX_SAFE_INTEGER; - } + } return parseInt(expandDepth, 10); - + } diff --git a/apps/client/src/widgets/collections/legacy/utils.ts b/apps/client/src/widgets/collections/legacy/utils.ts index 6432ce1d2f..5baa360e24 100644 --- a/apps/client/src/widgets/collections/legacy/utils.ts +++ b/apps/client/src/widgets/collections/legacy/utils.ts @@ -1,4 +1,5 @@ import { useMemo } from "preact/hooks"; + import FNote from "../../../entities/fnote"; /** @@ -12,9 +13,9 @@ export function useFilteredNoteIds(note: FNote, noteIds: string[]) { }, [ note, noteIds ]); } -export async function filterChildNotes(note: FNote) { +export async function filterChildNotes(note: FNote, includeArchived = true) { const imageLinks = note.getRelations("imageLink"); const imageLinkNoteIds = new Set(imageLinks.map(rel => rel.value)); const childNotes = await note.getChildNotes(); - return childNotes.filter((childNote) => !imageLinkNoteIds.has(childNote.noteId)); + return childNotes.filter((childNote) => !imageLinkNoteIds.has(childNote.noteId) && (includeArchived || !childNote.isArchived)); }