Skip to content

Commit 408073e

Browse files
committed
fix(note_list): subtree leaking into classic collections
1 parent 2695b7f commit 408073e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export function useNoteViewType(note?: FNote | null): ViewTypeOptions | undefine
147147
export function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOptions | undefined, ntxId: string | null | undefined) {
148148
const [ noteIds, setNoteIds ] = useState<string[]>([]);
149149
const [ includeArchived ] = useNoteLabelBoolean(note, "includeArchived");
150+
const directChildrenOnly = (viewType === "list" || viewType === "grid" || viewType === "table" || note?.type === "search");
150151

151152
async function refreshNoteIds() {
152153
if (!note) {
@@ -157,15 +158,17 @@ export function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOpt
157158
}
158159

159160
async function getNoteIds(note: FNote) {
160-
if (viewType === "list" || viewType === "grid" || viewType === "table" || note.type === "search") {
161+
if (directChildrenOnly) {
161162
return await note.getChildNoteIdsWithArchiveFiltering(includeArchived);
162163
} else {
163164
return await note.getSubtreeNoteIds(includeArchived);
164165
}
165166
}
166167

167168
// Refresh on note switch.
168-
useEffect(() => { refreshNoteIds() }, [ note, includeArchived ]);
169+
useEffect(() => {
170+
refreshNoteIds()
171+
}, [ note, includeArchived, directChildrenOnly ]);
169172

170173
// Refresh on alterations to the note subtree.
171174
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {

0 commit comments

Comments
 (0)