From 965b23bef4269ddc0275c393f9c75d5048890f91 Mon Sep 17 00:00:00 2001 From: Hamlet Jiang Su Date: Wed, 12 Jun 2024 15:32:44 -0700 Subject: [PATCH] fixed issue where experimental post page was not paginating comments --- lib/post/pages/post_page.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/post/pages/post_page.dart b/lib/post/pages/post_page.dart index ea0849b73..72579d749 100644 --- a/lib/post/pages/post_page.dart +++ b/lib/post/pages/post_page.dart @@ -60,6 +60,18 @@ class _PostPageState extends State { /// Whether the user changed during the course of viewing the post bool userChanged = false; + @override + void initState() { + super.initState(); + + scrollController.addListener(() { + // Fetches new comments when the user has scrolled past 70% list + if (scrollController.position.pixels > scrollController.position.maxScrollExtent * 0.7 && context.read().state.status == PostStatus.success) { + context.read().add(const GetPostCommentsEvent()); + } + }); + } + @override Widget build(BuildContext context) { final theme = Theme.of(context);