Avoid mutating memoized sidebar registries
Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
02ea090cb4
commit
72cd4a39d2
1 file changed
+20
-22
@@ -3246,29 +3246,27 @@ export default function Sidebar() {
|
||||
dragInProgressRef.current = false;
|
||||
}, []);
|
||||
|
||||
const animatedProjectLists = useMemo(() => new WeakSet<HTMLElement>(), []);
|
||||
const attachProjectListAutoAnimateRef = useCallback(
|
||||
(node: HTMLElement | null) => {
|
||||
if (!node || animatedProjectLists.has(node)) {
|
||||
return;
|
||||
}
|
||||
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
|
||||
animatedProjectLists.add(node);
|
||||
},
|
||||
[animatedProjectLists],
|
||||
);
|
||||
const animatedProjectListsRef = useRef<WeakSet<HTMLElement> | null>(null);
|
||||
const attachProjectListAutoAnimateRef = useCallback((node: HTMLElement | null) => {
|
||||
const animatedProjectLists =
|
||||
animatedProjectListsRef.current ?? (animatedProjectListsRef.current = new WeakSet());
|
||||
if (!node || animatedProjectLists.has(node)) {
|
||||
return;
|
||||
}
|
||||
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
|
||||
animatedProjectLists.add(node);
|
||||
}, []);
|
||||
|
||||
const animatedThreadLists = useMemo(() => new WeakSet<HTMLElement>(), []);
|
||||
const attachThreadListAutoAnimateRef = useCallback(
|
||||
(node: HTMLElement | null) => {
|
||||
if (!node || animatedThreadLists.has(node)) {
|
||||
return;
|
||||
}
|
||||
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
|
||||
animatedThreadLists.add(node);
|
||||
},
|
||||
[animatedThreadLists],
|
||||
);
|
||||
const animatedThreadListsRef = useRef<WeakSet<HTMLElement> | null>(null);
|
||||
const attachThreadListAutoAnimateRef = useCallback((node: HTMLElement | null) => {
|
||||
const animatedThreadLists =
|
||||
animatedThreadListsRef.current ?? (animatedThreadListsRef.current = new WeakSet());
|
||||
if (!node || animatedThreadLists.has(node)) {
|
||||
return;
|
||||
}
|
||||
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
|
||||
animatedThreadLists.add(node);
|
||||
}, []);
|
||||
|
||||
const visibleThreads = useMemo(
|
||||
() => sidebarThreads.filter((thread) => thread.archivedAt === null),
|
||||
|
||||
Reference in new issue
Block a user