Fix several potential memory leaks (#5586)
This commit is contained in:
parent
3405d62523
commit
37617b4b8e
@ -144,6 +144,8 @@ export function animateOpening(isArchived?: boolean) {
|
||||
}
|
||||
toggleAvatar?.classList.remove('animating');
|
||||
peer.classList.remove('animating');
|
||||
|
||||
callbacks.delete(cb);
|
||||
});
|
||||
}, ANIMATION_DURATION + ANIMATION_END_DELAY);
|
||||
|
||||
@ -283,6 +285,8 @@ export function animateClosing(isArchived?: boolean) {
|
||||
peer.classList.remove('animating');
|
||||
toggleAvatar!.classList.remove('animating');
|
||||
});
|
||||
|
||||
callbacks.delete(cb);
|
||||
}, ANIMATION_DURATION + ANIMATION_END_DELAY);
|
||||
|
||||
callbacks.add(cb);
|
||||
|
||||
@ -163,6 +163,7 @@ export function useIntersectionObserver({
|
||||
function destroy() {
|
||||
callbacks.clear();
|
||||
observer.disconnect();
|
||||
entriesAccumulator.clear();
|
||||
}
|
||||
|
||||
controllerRef.current = {
|
||||
|
||||
@ -722,6 +722,8 @@ function useEffectBase(
|
||||
};
|
||||
}
|
||||
|
||||
if (effectConfig) effectConfig.schedule = undefined; // Help GC
|
||||
|
||||
byCursor[cursor] = {
|
||||
...effectConfig,
|
||||
dependencies,
|
||||
|
||||
@ -57,8 +57,17 @@ export default function animateHorizontalScroll(container: HTMLElement, left: nu
|
||||
|
||||
const startAt = Date.now();
|
||||
|
||||
function cleanup() {
|
||||
container.style.scrollSnapType = '';
|
||||
delete container.dataset.scrollId;
|
||||
stopById.delete(id);
|
||||
}
|
||||
|
||||
animate(() => {
|
||||
if (isStopped) return false;
|
||||
if (isStopped) {
|
||||
cleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
const t = Math.min((Date.now() - startAt) / duration, 1);
|
||||
|
||||
@ -66,9 +75,7 @@ export default function animateHorizontalScroll(container: HTMLElement, left: nu
|
||||
container.scrollLeft = Math.round(target - currentPath);
|
||||
|
||||
if (t >= 1) {
|
||||
container.style.scrollSnapType = '';
|
||||
delete container.dataset.scrollId;
|
||||
stopById.delete(id);
|
||||
cleanup();
|
||||
resolve();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user