Revert flush to cancel, speed up scroll position caching

Somehow the flush cache the scroll position for a different status ID
This commit is contained in:
Lim Chee Aun 2023-02-20 20:59:46 +08:00
parent 6e9661a70c
commit 8e4ecd242b

View file

@ -62,13 +62,13 @@ function StatusPage() {
if (uiState !== 'loading') { if (uiState !== 'loading') {
states.scrollPositions[id] = scrollTop; states.scrollPositions[id] = scrollTop;
} }
}, 100); }, 50);
scrollableRef.current.addEventListener('scroll', onScroll, { scrollableRef.current.addEventListener('scroll', onScroll, {
passive: true, passive: true,
}); });
onScroll(); onScroll();
return () => { return () => {
onScroll.flush(); onScroll.cancel();
scrollableRef.current?.removeEventListener('scroll', onScroll); scrollableRef.current?.removeEventListener('scroll', onScroll);
}; };
}, [id, uiState !== 'loading']); }, [id, uiState !== 'loading']);