Skip to content

Commit

Permalink
fix: 楼中楼评论请求重复 #284
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhigq committed Mar 7, 2024
1 parent ab24da5 commit 3bf6136
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
20 changes: 4 additions & 16 deletions lib/pages/video/detail/reply_reply/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class VideoReplyReplyController extends GetxController {
if (type == 'init') {
currentPage = 0;
}
if (isLoadingMore) {
return;
}
isLoadingMore = true;
final res = await ReplyHttp.replyReplyList(
oid: aid!,
Expand All @@ -41,7 +44,7 @@ class VideoReplyReplyController extends GetxController {
final List<ReplyItemModel> replies = res['data'].replies;
if (replies.isNotEmpty) {
noMore.value = '加载中...';
if (replyList.length == res['data'].page.count) {
if (replies.length == res['data'].page.count) {
noMore.value = '没有更多了';
}
currentPage++;
Expand All @@ -50,21 +53,6 @@ class VideoReplyReplyController extends GetxController {
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
}
if (type == 'init') {
// List<ReplyItemModel> replies = res['data'].replies;
// 添加置顶回复
// if (res['data'].upper.top != null) {
// bool flag = false;
// for (var i = 0; i < res['data'].topReplies.length; i++) {
// if (res['data'].topReplies[i].rpid == res['data'].upper.top.rpid) {
// flag = true;
// }
// }
// if (!flag) {
// replies.insert(0, res['data'].upper.top);
// }
// }
// replies.insertAll(0, res['data'].topReplies);
// res['data'].replies = replies;
replyList.value = replies;
} else {
// 每次回复之后,翻页请求有且只有相同的一条回复数据
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/video/detail/reply_reply/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
() {
if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent - 300) {
EasyThrottle.throttle('replylist', const Duration(seconds: 2), () {
EasyThrottle.throttle('replylist', const Duration(milliseconds: 200),
() {
_videoReplyReplyController.queryReplyList(type: 'onLoad');
});
}
Expand Down

0 comments on commit 3bf6136

Please sign in to comment.