From 91aaa1b5190424f1370b4a9dc666761d4c042ded Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 31 Oct 2024 23:22:29 +0800 Subject: [PATCH] fix: replyreply load --- .../video/detail/reply_reply/controller.dart | 15 ++++++++------- lib/pages/video/detail/reply_reply/view.dart | 3 +-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/pages/video/detail/reply_reply/controller.dart b/lib/pages/video/detail/reply_reply/controller.dart index 506e530e..9cf88282 100644 --- a/lib/pages/video/detail/reply_reply/controller.dart +++ b/lib/pages/video/detail/reply_reply/controller.dart @@ -16,7 +16,7 @@ class VideoReplyReplyController extends GetxController { ReplyItemModel? rootReply; RxList replyList = [].obs; // 当前页 - int currentPage = 0; + int currentPage = 1; bool isLoadingMore = false; RxString noMore = ''.obs; // 当前回复的回复 @@ -25,12 +25,12 @@ class VideoReplyReplyController extends GetxController { @override void onInit() { super.onInit(); - currentPage = 0; + currentPage = 1; } Future queryReplyList({type = 'init', currentReply}) async { if (type == 'init') { - currentPage = 0; + currentPage = 1; } if (isLoadingMore) { return; @@ -39,7 +39,7 @@ class VideoReplyReplyController extends GetxController { final res = await ReplyHttp.replyReplyList( oid: aid!, root: rpid!, - pageNum: currentPage + 1, + pageNum: currentPage, type: replyType.index, ); if (res['status']) { @@ -50,12 +50,12 @@ class VideoReplyReplyController extends GetxController { if (replies.length == res['data'].page.count) { noMore.value = '没有更多了'; } - currentPage++; + // currentPage++; } else { // 未登录状态replies可能返回null - noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了'; + noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了'; } - if (type == 'init') { + if (type == 'init' && currentPage == 1) { replyList.value = replies; } else { // 每次回复之后,翻页请求有且只有相同的一条回复数据 @@ -79,6 +79,7 @@ class VideoReplyReplyController extends GetxController { replyList.insert(0, currentReply); } } + currentPage += 1; isLoadingMore = false; return res; } diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 8ac24302..8da8e535 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -183,8 +183,7 @@ class _VideoReplyReplyPanelState extends State { Expanded( child: RefreshIndicator( onRefresh: () async { - setState(() {}); - _videoReplyReplyController.currentPage = 0; + _videoReplyReplyController.currentPage = 1; return await _videoReplyReplyController.queryReplyList( currentReply: widget.currentReply, );