From 524370711c0856be8b3efb4aff543bb96da102ce Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Tue, 15 Jun 2021 15:17:08 +0800 Subject: [PATCH] WaitUntilOnPage: Reduce debounce ms; remove unused hack (1) Reduced the debouncing duration so that the final element can be rendered asap after visible. - If the user is scrolling non-stop, it would continue to debounce and the GUI ends up not showing the final element. - 25ms seems enough to prevent the initial false-positive that occurs in the scenario of "adjacent/upper elements resized late, so our element was briefly on screen when mounted". If not enough, we can make this a parameter. (2) Removed `lastUpdateDate` that was a quick hack for Recommended section. We don't use it on that element anymore, so remove the hack to keep the file clean. --- ui/component/common/wait-until-on-page.jsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ui/component/common/wait-until-on-page.jsx b/ui/component/common/wait-until-on-page.jsx index d37b4cd78..53cb9886e 100644 --- a/ui/component/common/wait-until-on-page.jsx +++ b/ui/component/common/wait-until-on-page.jsx @@ -2,11 +2,10 @@ import React from 'react'; import debounce from 'util/debounce'; -const DEBOUNCE_SCROLL_HANDLER_MS = 300; +const DEBOUNCE_SCROLL_HANDLER_MS = 25; type Props = { children: any, - lastUpdateDate?: any, skipWait?: boolean, placeholder?: any, }; @@ -15,10 +14,6 @@ export default function WaitUntilOnPage(props: Props) { const ref = React.useRef(); const [shouldRender, setShouldRender] = React.useState(false); - React.useEffect(() => { - setShouldRender(false); - }, [props.lastUpdateDate]); - React.useEffect(() => { const handleDisplayingRef = debounce((e) => { const element = ref && ref.current;