🐛 Bug fixes

This commit is contained in:
LittleSheep 2024-03-24 11:07:36 +08:00
parent 06b4cb863e
commit 41f456893f
2 changed files with 5 additions and 4 deletions

View File

@ -47,11 +47,12 @@ class _ExploreScreenState extends State<ExploreScreen> {
if (res.statusCode == 200) { if (res.statusCode == 200) {
final result = final result =
PaginationResult.fromJson(jsonDecode(utf8.decode(res.bodyBytes))); PaginationResult.fromJson(jsonDecode(utf8.decode(res.bodyBytes)));
final isLastPage = (result.data?.length ?? 0) < pageSize; final isLastPage = (result.count - pageKey) < pageSize;
if (isLastPage) { if (isLastPage || result.data == null) {
paginationController.appendLastPage(feed); paginationController.appendLastPage(feed);
} else { } 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; final nextPageKey = pageKey + feed.length;
paginationController.appendPage(feed, nextPageKey); paginationController.appendPage(feed, nextPageKey);
} }

View File

@ -22,7 +22,7 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
bool showRecommendationBanner = true; bool showRecommendationBanner = true;
Future<void> postMoment() async { Future<void> postMoment() async {
if (authClient.client == null) return; if (!await authClient.isAuthorized()) return;
setState(() => isSubmitting = true); setState(() => isSubmitting = true);
var res = await authClient.client!.post( var res = await authClient.client!.post(