From 9f8f6b55a55f65b59478cb178dfbbbbaacd27b9d Mon Sep 17 00:00:00 2001 From: john Date: Sat, 3 May 2025 23:43:59 +0200 Subject: [PATCH] idk --- src/pages/FeedView.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/pages/FeedView.tsx b/src/pages/FeedView.tsx index 0ebad8a..5dc3f27 100644 --- a/src/pages/FeedView.tsx +++ b/src/pages/FeedView.tsx @@ -21,13 +21,11 @@ export default function FeedView({ loadPosts }: FeedViewProps) { const [hasMore, setHasMore] = useState(true) const cursor = useRef(null) const [isLoading, setIsLoading] = useState(false) - const loading = useRef(false) + const loading = useRef(false) const loadNextPage = useCallback(async () => { if (loading.current) return - loading.current = true - setIsLoading(true) try { const page = await loadPosts(cursor.current, PageSize) @@ -40,8 +38,8 @@ export default function FeedView({ loadPosts }: FeedViewProps) { setPages((prev) => [...prev, page]) } finally { - setIsLoading(false) loading.current = false + setIsLoading(false) } }, [loadPosts]) @@ -55,20 +53,20 @@ export default function FeedView({ loadPosts }: FeedViewProps) { } }, [loadNextPage]) - const loadButtonState = isLoading ? 'loading' : hasMore ? 'ready' : 'done' - return (
- + {hasMore && ( + + )}
) } interface LoadMoreButtonProps { - state: 'ready' | 'loading' | 'done' + state: 'ready' | 'loading' onClick: () => void } @@ -76,8 +74,6 @@ function LoadMoreButton({ state, onClick }: LoadMoreButtonProps) { const buttonClasses = 'w-full py-3 px-4 bg-gray-100 hover:bg-gray-200 text-gray-800 rounded-md flex items-center justify-center disabled:opacity-70' switch (state) { - case 'done': - return
that's all...
case 'loading': return (