diff --git a/.gitignore b/.gitignore index df674d3..a3ae63f 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,9 @@ next-env.d.ts .firebase/logs/vsce-debug.log AGENTS.md -# github +# ai .github/agents/** -.github/copilot-instructions.md \ No newline at end of file +.github/copilot-instructions.md +graphify-out +GEMINI.md +AGENTS.md \ No newline at end of file diff --git a/app/communities/page.tsx b/app/communities/page.tsx index 1d71a61..962aa49 100644 --- a/app/communities/page.tsx +++ b/app/communities/page.tsx @@ -7,9 +7,8 @@ import CommunityLoader from "@/components/loaders/CommunityLoader"; import useCommunitiesFeed from "@/hooks/community/useCommunitiesFeed"; import useCommunityState from "@/hooks/community/useCommunityState"; import useCommunityMembershipActions from "@/hooks/community/useCommunityMembershipActions"; -import { useIntersectionObserver } from "@/hooks/useIntersectionObserver"; -import { Box, Heading, Spinner, Stack, Text } from "@chakra-ui/react"; -import React, { useEffect, useMemo } from "react"; +import { Box, Button, Heading, Stack, Text } from "@chakra-ui/react"; +import React, { useMemo } from "react"; import { Community } from "@/types/community"; /** @@ -23,14 +22,6 @@ const Communities: React.FC = () => { const { onJoinOrLeaveCommunity } = useCommunityMembershipActions(); const { communities, loading, fetchCommunities, noMoreCommunities } = useCommunitiesFeed({ limitValue: 10, isPagination: true }); - const observerOptions = useMemo(() => ({ threshold: 0.5 }), []); - const { ref, isIntersecting } = useIntersectionObserver(observerOptions); - - useEffect(() => { - if (isIntersecting && !loading && !noMoreCommunities) { - fetchCommunities(false); - } - }, [isIntersecting, loading, noMoreCommunities, fetchCommunities]); const [adminCommunities, subscribedCommunities, notSubscribedCommunities] = useMemo(() => { @@ -127,16 +118,15 @@ const Communities: React.FC = () => { )} {!noMoreCommunities ? ( - fetchCommunities(false)} + loading={loading} + variant="outline" + width="100%" + my={4} > - {loading && } - + Load More + ) : ( No more communities diff --git a/app/page.tsx b/app/page.tsx index 32372c9..6389cd1 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -15,7 +15,7 @@ import usePostVote from "@/hooks/posts/usePostVote"; import usePostVoteSync from "@/hooks/posts/usePostVoteSync"; import usePostsFeed from "@/hooks/posts/usePostsFeed"; import useCustomToast from "@/hooks/useCustomToast"; -import { Box, Spinner, Stack, Text } from "@chakra-ui/react"; +import { Button, Stack, Text } from "@chakra-ui/react"; import { useEffect, useMemo } from "react"; import { useAuthState } from "react-firebase-hooks/auth"; @@ -43,7 +43,7 @@ export default function Home() { [communityStateValue.mySnippets] ); - const { loading, fetchPosts, ref, noMorePosts } = usePostsFeed({ + const { loading, fetchPosts, noMorePosts } = usePostsFeed({ communityIds: user && communityIds.length > 0 ? communityIds : undefined, isGenericHome: !user || communityIds.length === 0, }); @@ -116,15 +116,15 @@ export default function Home() { /> ))} {!noMorePosts ? ( - fetchPosts(false)} + loading={loading} + variant="outline" + width="100%" + my={4} > - {loading && } - + Load More + ) : ( No more posts diff --git a/components/navbar/directory/MenuListItem.tsx b/components/navbar/directory/MenuListItem.tsx index be76c37..4e04b3a 100644 --- a/components/navbar/directory/MenuListItem.tsx +++ b/components/navbar/directory/MenuListItem.tsx @@ -39,6 +39,7 @@ const MenuListItem: React.FC = ({ return ( = ({ communityData }) => { usePostVoteSync(setPostStateValue); const { isAdmin, canPost } = useCommunityPermissions(communityData); - const { loading, fetchPosts, ref, noMorePosts } = usePostsFeed({ + const { loading, fetchPosts, noMorePosts } = usePostsFeed({ communityId: communityData.id, }); @@ -67,15 +67,15 @@ const Posts: React.FC = ({ communityData }) => { /> ))} {!noMorePosts ? ( - fetchPosts(false)} + loading={loading} + variant="outline" + width="100%" + my={4} > - {loading && } - + Load More + ) : ( No more posts diff --git a/components/ui/CustomMenuButton.tsx b/components/ui/CustomMenuButton.tsx index 72afc5e..5ee40ef 100644 --- a/components/ui/CustomMenuButton.tsx +++ b/components/ui/CustomMenuButton.tsx @@ -21,6 +21,7 @@ const CustomMenuButton: React.FC = ({ }) => { return ( ({ threshold: 0.5 }), []); - const { ref, isIntersecting } = useIntersectionObserver(observerOptions); - const fetchPosts = async (initial = false) => { if (loading) return; if (!initial && noMorePosts) return; @@ -74,13 +70,6 @@ const usePostsFeed = ({ } }; - useEffect(() => { - if (isIntersecting && !loading && !noMorePosts && lastVisible) { - fetchPosts(false); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isIntersecting, loading, noMorePosts, lastVisible]); - useEffect(() => { setNoMorePosts(false); setLastVisible(null); @@ -100,7 +89,6 @@ const usePostsFeed = ({ return { loading, fetchPosts, - ref, noMorePosts, }; };