From d2fb86036c04f64fd5d9cc29604657b97ec4652b Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 1 Jan 2024 18:29:21 +0800 Subject: [PATCH 01/23] Remove DEV check It refers to local dev, not the dev site --- src/components/media-modal.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/media-modal.jsx b/src/components/media-modal.jsx index 968988bf5..8508fe2b7 100644 --- a/src/components/media-modal.jsx +++ b/src/components/media-modal.jsx @@ -295,8 +295,7 @@ function MediaModal({ Open original media - {import.meta.env.DEV && // Only dev for now - !!states.settings.mediaAltGenerator && + {!!states.settings.mediaAltGenerator && !!IMG_ALT_API_URL && !!mediaAttachments[currentIndex]?.url && !mediaAttachments[currentIndex]?.description && From b168707c1448235f77e9ef439abc467df68e68e0 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 1 Jan 2024 18:31:59 +0800 Subject: [PATCH 02/23] Revert "Remove DEV check" This reverts commit d2fb86036c04f64fd5d9cc29604657b97ec4652b. --- src/components/media-modal.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/media-modal.jsx b/src/components/media-modal.jsx index 8508fe2b7..968988bf5 100644 --- a/src/components/media-modal.jsx +++ b/src/components/media-modal.jsx @@ -295,7 +295,8 @@ function MediaModal({ Open original media - {!!states.settings.mediaAltGenerator && + {import.meta.env.DEV && // Only dev for now + !!states.settings.mediaAltGenerator && !!IMG_ALT_API_URL && !!mediaAttachments[currentIndex]?.url && !mediaAttachments[currentIndex]?.description && From cf52e0776ef43535afed491f272c91c214830c9b Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 2 Jan 2024 12:20:36 +0800 Subject: [PATCH 03/23] Don't need reachStart from useScroll --- src/pages/search.jsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/search.jsx b/src/pages/search.jsx index e55440ad7..7c4f6ea32 100644 --- a/src/pages/search.jsx +++ b/src/pages/search.jsx @@ -17,7 +17,6 @@ import { api } from '../utils/api'; import { fetchRelationships } from '../utils/relationships'; import shortenNumber from '../utils/shorten-number'; import usePageVisibility from '../utils/usePageVisibility'; -import useScroll from '../utils/useScroll'; import useTitle from '../utils/useTitle'; const SHORT_LIMIT = 5; @@ -151,11 +150,9 @@ function Search({ columnMode, ...props }) { })(); } - const { reachStart } = useScroll({ - scrollableRef, - }); const lastHiddenTime = useRef(); usePageVisibility((visible) => { + const reachStart = scrollableRef.current?.scrollTop === 0; if (visible && reachStart) { const timeDiff = Date.now() - lastHiddenTime.current; if (!lastHiddenTime.current || timeDiff > 1000 * 3) { From 0ebbc5b34ecedf7886726d8a457318debe50b41a Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 2 Jan 2024 12:24:03 +0800 Subject: [PATCH 04/23] Don't need nearReachEnd, use InView more --- src/components/timeline.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/timeline.jsx b/src/components/timeline.jsx index 255330181..3af0f3df3 100644 --- a/src/components/timeline.jsx +++ b/src/components/timeline.jsx @@ -239,9 +239,10 @@ function Timeline({ setNearReachStart(nearReachStart); if (reachStart) { loadItems(true); - } else if (nearReachEnd || (reachEnd && showMore)) { - loadItems(); } + // else if (nearReachEnd || (reachEnd && showMore)) { + // loadItems(); + // } }, [], ); @@ -451,6 +452,8 @@ function Timeline({ {uiState === 'default' && (showMore ? ( { if (inView) { loadItems(); From df393ae959330ad21f43aedd3026be21da8a9a52 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 2 Jan 2024 12:25:01 +0800 Subject: [PATCH 05/23] Use InView to replace nearReachStart --- src/pages/status.jsx | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index e52ee7e03..2ae42c704 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -545,7 +545,6 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { const ancestors = statuses.filter((s) => s.ancestor); const [heroInView, setHeroInView] = useState(true); - const onView = useDebouncedCallback(setHeroInView, 100); const heroPointer = useMemo(() => { // get top offset of heroStatus if (!heroStatusRef.current || heroInView) return null; @@ -652,10 +651,11 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { } }); - const { nearReachStart } = useScroll({ - scrollableRef, - distanceFromStartPx: 16, - }); + const [reachTopPost, setReachTopPost] = useState(false); + // const { nearReachStart } = useScroll({ + // scrollableRef, + // distanceFromStartPx: 16, + // }); const initialPageState = useRef(showMedia ? 'media+status' : 'status'); @@ -693,7 +693,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { }, [mediaStatusID, showMedia]); const renderStatus = useCallback( - (status) => { + (status, i) => { const { id: statusID, ancestor, @@ -735,7 +735,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { <> @@ -810,15 +810,21 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { resetScrollPosition(statusID); }} > - + + + {ancestor && repliesCount > 1 && ( ); } From b4d4c61128dbaddeabdf6694926e514d13e3a2cc Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 2 Jan 2024 19:56:54 +0800 Subject: [PATCH 12/23] Experiment delay render items in carousel --- src/components/timeline.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/timeline.jsx b/src/components/timeline.jsx index 2939c8eb7..7e792c4ae 100644 --- a/src/components/timeline.jsx +++ b/src/components/timeline.jsx @@ -714,6 +714,13 @@ function StatusCarousel({ title, class: className, children }) { // init?.(); // }, []); + const [render, setRender] = useState(false); + useEffect(() => { + setTimeout(() => { + setRender(true); + }, 1); + }, []); + return (