From 41f456893f96d245d6d41e69c9b7f01f2a272f3a Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 24 Mar 2024 11:07:36 +0800 Subject: [PATCH] :bug: Bug fixes --- lib/screens/explore.dart | 7 ++++--- lib/screens/publish/moment_editor.dart | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) 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(