diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index efe791d..a94d3f3 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -47,11 +47,12 @@ class _ExploreScreenState extends State { if (res.statusCode == 200) { final result = PaginationResult.fromJson(jsonDecode(utf8.decode(res.bodyBytes))); - final isLastPage = (result.data?.length ?? 0) < pageSize; - if (isLastPage) { + final isLastPage = (result.count - pageKey) < pageSize; + if (isLastPage || result.data == null) { paginationController.appendLastPage(feed); } else { - final feed = result.data!.map((x) => Feed.fromJson(x)).toList(); + final feed = + result.data?.map((x) => Feed.fromJson(x)).toList() ?? List.empty(); final nextPageKey = pageKey + feed.length; paginationController.appendPage(feed, nextPageKey); } diff --git a/lib/screens/publish/moment_editor.dart b/lib/screens/publish/moment_editor.dart index 02cd4a8..9e6db30 100644 --- a/lib/screens/publish/moment_editor.dart +++ b/lib/screens/publish/moment_editor.dart @@ -22,7 +22,7 @@ class _MomentEditorScreenState extends State { bool showRecommendationBanner = true; Future postMoment() async { - if (authClient.client == null) return; + if (!await authClient.isAuthorized()) return; setState(() => isSubmitting = true); var res = await authClient.client!.post(