Comment view

This commit is contained in:
2024-03-24 12:12:13 +08:00
parent b32a7216b5
commit c4157c3e23
3 changed files with 132 additions and 5 deletions

View File

@ -48,13 +48,13 @@ class _ExploreScreenState extends State<ExploreScreen> {
final result =
PaginationResult.fromJson(jsonDecode(utf8.decode(res.bodyBytes)));
final isLastPage = (result.count - pageKey) < pageSize;
final items =
result.data?.map((x) => Feed.fromJson(x)).toList() ?? List.empty();
if (isLastPage || result.data == null) {
paginationController.appendLastPage(feed);
paginationController.appendLastPage(items);
} else {
final feed =
result.data?.map((x) => Feed.fromJson(x)).toList() ?? List.empty();
final nextPageKey = pageKey + feed.length;
paginationController.appendPage(feed, nextPageKey);
final nextPageKey = pageKey + items.length;
paginationController.appendPage(items, nextPageKey);
}
} else {
paginationController.error = utf8.decode(res.bodyBytes);