Skip to content

Commit

Permalink
Update page.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanAnsari authored Sep 28, 2024
1 parent 00e0742 commit 8c2582b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function Dashboard() {
const [input, setInput] = useState("");
const [output, setOutput] = useState("");
const [previousContent, setPreviousContent] = useState<DocumentData[]>([]); // Define state as an array of DocumentData
const [lastVisible, setLastVisible] = useState<DocumentData | null>(null);
const [isLoading, setIsLoading] = useState(false); // Add loading state
const router = useRouter();

Expand All @@ -41,6 +42,20 @@ export default function Dashboard() {
};

fetchPreviousContent();

const fetchMoreContent = async () => {
try {
const { content, lastVisible: newLastVisible } = await getPreviousContent(
session?.user?.email as string,
lastVisible
);
setPreviousContent([...previousContent, ...content]);
setLastVisible(newLastVisible);
} catch (error) {
console.error("Error fetching more content:", error);
toast.error("Failed to load more content.");
}
};
}
}, [session]);

Expand Down

0 comments on commit 8c2582b

Please sign in to comment.