fix: replyreply load
This commit is contained in:
@ -16,7 +16,7 @@ class VideoReplyReplyController extends GetxController {
|
|||||||
ReplyItemModel? rootReply;
|
ReplyItemModel? rootReply;
|
||||||
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
||||||
// 当前页
|
// 当前页
|
||||||
int currentPage = 0;
|
int currentPage = 1;
|
||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
RxString noMore = ''.obs;
|
RxString noMore = ''.obs;
|
||||||
// 当前回复的回复
|
// 当前回复的回复
|
||||||
@ -25,12 +25,12 @@ class VideoReplyReplyController extends GetxController {
|
|||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
currentPage = 0;
|
currentPage = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future queryReplyList({type = 'init', currentReply}) async {
|
Future queryReplyList({type = 'init', currentReply}) async {
|
||||||
if (type == 'init') {
|
if (type == 'init') {
|
||||||
currentPage = 0;
|
currentPage = 1;
|
||||||
}
|
}
|
||||||
if (isLoadingMore) {
|
if (isLoadingMore) {
|
||||||
return;
|
return;
|
||||||
@ -39,7 +39,7 @@ class VideoReplyReplyController extends GetxController {
|
|||||||
final res = await ReplyHttp.replyReplyList(
|
final res = await ReplyHttp.replyReplyList(
|
||||||
oid: aid!,
|
oid: aid!,
|
||||||
root: rpid!,
|
root: rpid!,
|
||||||
pageNum: currentPage + 1,
|
pageNum: currentPage,
|
||||||
type: replyType.index,
|
type: replyType.index,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
@ -50,12 +50,12 @@ class VideoReplyReplyController extends GetxController {
|
|||||||
if (replies.length == res['data'].page.count) {
|
if (replies.length == res['data'].page.count) {
|
||||||
noMore.value = '没有更多了';
|
noMore.value = '没有更多了';
|
||||||
}
|
}
|
||||||
currentPage++;
|
// currentPage++;
|
||||||
} else {
|
} else {
|
||||||
// 未登录状态replies可能返回null
|
// 未登录状态replies可能返回null
|
||||||
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
|
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
||||||
}
|
}
|
||||||
if (type == 'init') {
|
if (type == 'init' && currentPage == 1) {
|
||||||
replyList.value = replies;
|
replyList.value = replies;
|
||||||
} else {
|
} else {
|
||||||
// 每次回复之后,翻页请求有且只有相同的一条回复数据
|
// 每次回复之后,翻页请求有且只有相同的一条回复数据
|
||||||
@ -79,6 +79,7 @@ class VideoReplyReplyController extends GetxController {
|
|||||||
replyList.insert(0, currentReply);
|
replyList.insert(0, currentReply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
currentPage += 1;
|
||||||
isLoadingMore = false;
|
isLoadingMore = false;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,8 +183,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: RefreshIndicator(
|
child: RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
setState(() {});
|
_videoReplyReplyController.currentPage = 1;
|
||||||
_videoReplyReplyController.currentPage = 0;
|
|
||||||
return await _videoReplyReplyController.queryReplyList(
|
return await _videoReplyReplyController.queryReplyList(
|
||||||
currentReply: widget.currentReply,
|
currentReply: widget.currentReply,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user