Skip to content

Commit

Permalink
remove memoization from infinite scroll, add origin to lens client
Browse files Browse the repository at this point in the history
  • Loading branch information
kualta committed Jun 27, 2024
1 parent d4d7b47 commit 890f909
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/InfiniteScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -33,7 +33,7 @@ export const InfiniteScroll = ({ initialData, initialCursor, endpoint }) => {
} finally {
setLoading(false);
}
}, [cursor, loading]);
};

useEffect(() => {
const handleScroll = () => {
Expand All @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion src/utils/getLensClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit 890f909

Please sign in to comment.