Skip to content

Commit 20b301a

Browse files
committed
fix(collections/list): archived notes not shown on first render
1 parent bacbe9f commit 20b301a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apps/client/src/widgets/react/hooks.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,17 @@ export function useNoteLabelWithDefault(note: FNote | undefined | null, labelNam
406406
}
407407

408408
export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: FilterLabelsByType<boolean>): [ boolean, (newValue: boolean) => void] {
409-
const [ labelValue, setLabelValue ] = useState<boolean>(!!note?.hasLabel(labelName));
409+
const [, forceRender] = useState({});
410410

411-
useEffect(() => setLabelValue(!!note?.hasLabel(labelName)), [ note ]);
411+
useEffect(() => {
412+
forceRender({});
413+
}, [ note ]);
412414

413415
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
414416
for (const attr of loadResults.getAttributeRows()) {
415417
if (attr.type === "label" && attr.name === labelName && attributes.isAffecting(attr, note)) {
416-
setLabelValue(!attr.isDeleted);
418+
forceRender({});
419+
break;
417420
}
418421
}
419422
});
@@ -430,6 +433,7 @@ export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: F
430433

431434
useDebugValue(labelName);
432435

436+
const labelValue = !!note?.hasLabel(labelName);
433437
return [ labelValue, setter ] as const;
434438
}
435439

0 commit comments

Comments
 (0)