From 890f909520a8270ceb04f4cd2eb0a2556f1e0d4d Mon Sep 17 00:00:00 2001 From: kualta Date: Thu, 27 Jun 2024 11:09:28 +0000 Subject: [PATCH] remove memoization from infinite scroll, add origin to lens client --- src/components/InfiniteScroll.tsx | 6 +++--- src/utils/getLensClient.ts | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/InfiniteScroll.tsx b/src/components/InfiniteScroll.tsx index d71cb55..e914ecf 100644 --- a/src/components/InfiniteScroll.tsx +++ b/src/components/InfiniteScroll.tsx @@ -10,7 +10,7 @@ export const InfiniteScroll = ({ initialData, initialCursor, endpoint }) => { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); - const loadMorePosts = useCallback(async () => { + const loadMorePosts = async () => { if (loading || !cursor) return; setLoading(true); @@ -33,7 +33,7 @@ export const InfiniteScroll = ({ initialData, initialCursor, endpoint }) => { } finally { setLoading(false); } - }, [cursor, loading]); + }; useEffect(() => { const handleScroll = () => { @@ -49,7 +49,7 @@ export const InfiniteScroll = ({ initialData, initialCursor, endpoint }) => { window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); - }, [loadMorePosts]); + }, []); if (error) throw new Error(error); diff --git a/src/utils/getLensClient.ts b/src/utils/getLensClient.ts index b1df0c7..ad7e67a 100644 --- a/src/utils/getLensClient.ts +++ b/src/utils/getLensClient.ts @@ -7,9 +7,12 @@ export const getLensClient = async () => { const { refreshToken } = getCookieAuth(); const client = new LensClient({ environment: production, + headers: { + origin: "https://pingpad.io", + }, storage: window?.localStorage, }); - console.log(window, window?.localStorage); + if (refreshToken) { await client.authentication.authenticateWith({ refreshToken });