diff --git a/lib/pages/bangumi/controller.dart b/lib/pages/bangumi/controller.dart index 2f26a1f88..664e748e0 100644 --- a/lib/pages/bangumi/controller.dart +++ b/lib/pages/bangumi/controller.dart @@ -57,19 +57,41 @@ class BangumiController extends CommonListController< type: tabType == TabType.bangumi ? 1 : 2, pn: followPage, ); + if (res is Success) { BangumiListDataModel data = res.response; - followPage++; - followEnd = data.hasNext == 0 || data.list.isNullOrEmpty; + List? list = data.list; followCount.value = data.total ?? -1; - if (isRefresh.not && followState.value is Success) { - data.list?.insertAll(0, (followState.value as Success).response); + if (data.hasNext == 0) { + followEnd = true; } - followState.value = LoadingState.success(data.list); + + if (list.isNullOrEmpty) { + followEnd = true; + if (isRefresh) { + followState.value = LoadingState.success(list); + } + followLoading = false; + return; + } + if (isRefresh) { + if (list!.length >= followCount.value) { + followEnd = true; + } + followState.value = LoadingState.success(list); followController?.animToTop(); + } else if (followState.value is Success) { + List currentList = + (followState.value as Success).response; + currentList.addAll(list!); + if (currentList.length >= followCount.value) { + followEnd = true; + } + followState.refresh(); } - } else { + followPage++; + } else if (isRefresh) { followState.value = res; } followLoading = false; diff --git a/lib/pages/common/common_controller.dart b/lib/pages/common/common_controller.dart index 63e4e7ed2..da7ef3b5d 100644 --- a/lib/pages/common/common_controller.dart +++ b/lib/pages/common/common_controller.dart @@ -36,6 +36,7 @@ abstract class CommonController extends GetxController bool isLoading = false; late bool isEnd = false; Rx get loadingState; + bool? isReply; Future> customGetData(); @@ -66,6 +67,8 @@ abstract class CommonController extends GetxController isEnd = true; if (isRefresh) { loadingState.value = LoadingState?>.success(dataList); + } else if (isReply == true) { + loadingState.refresh(); } isLoading = false; return; diff --git a/lib/pages/common/reply_controller.dart b/lib/pages/common/reply_controller.dart index 102eaf1e9..8c4c20b87 100644 --- a/lib/pages/common/reply_controller.dart +++ b/lib/pages/common/reply_controller.dart @@ -35,6 +35,9 @@ abstract class ReplyController extends CommonListController { late Rx mode = Mode.MAIN_LIST_HOT.obs; late bool hasUpTop = false; + @override + bool? get isReply => true; + late final antiGoodsReply = GStorage.antiGoodsReply; // comment antifraud diff --git a/lib/pages/live/controller.dart b/lib/pages/live/controller.dart index 5e6228401..56f8f92da 100644 --- a/lib/pages/live/controller.dart +++ b/lib/pages/live/controller.dart @@ -72,7 +72,7 @@ class LiveController loadingState.refresh(); } followPage++; - } else { + } else if (isRefresh) { followListState.value = LoadingState.error(res['msg']); } } diff --git a/lib/pages/member_search/controller.dart b/lib/pages/member_search/controller.dart index 69eeae638..c9db6434c 100644 --- a/lib/pages/member_search/controller.dart +++ b/lib/pages/member_search/controller.dart @@ -97,7 +97,9 @@ class MemberSearchController extends GetxController if (data.hasMore == false || items.isNullOrEmpty) { isEndDynamic = true; - dynamicState.value = LoadingState.success(items); + if (isRefresh) { + dynamicState.value = LoadingState.success(items); + } return; } @@ -138,7 +140,9 @@ class MemberSearchController extends GetxController if (vlist.isNullOrEmpty) { isEndArchive = true; - archiveState.value = LoadingState.success(vlist); + if (isRefresh) { + archiveState.value = LoadingState.success(vlist); + } return; } diff --git a/lib/pages/msg_feed_top/like_me/controller.dart b/lib/pages/msg_feed_top/like_me/controller.dart index 5dc195523..0e8a921e5 100644 --- a/lib/pages/msg_feed_top/like_me/controller.dart +++ b/lib/pages/msg_feed_top/like_me/controller.dart @@ -60,7 +60,7 @@ class LikeMeController extends CommonDataController { } else { pair.second.removeAt(index); } - loadingState.value = LoadingState.success(pair); + loadingState.refresh(); SmartDialog.showToast('删除成功'); } else { SmartDialog.showToast(res['msg']); diff --git a/lib/pages/video/detail/member/controller.dart b/lib/pages/video/detail/member/controller.dart index c931e517e..4411abec9 100644 --- a/lib/pages/video/detail/member/controller.dart +++ b/lib/pages/video/detail/member/controller.dart @@ -1,5 +1,6 @@ import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/member.dart'; +import 'package:PiliPlus/models/member/info.dart'; import 'package:PiliPlus/models/space_archive/data.dart'; import 'package:PiliPlus/models/space_archive/item.dart'; import 'package:PiliPlus/pages/common/common_data_controller.dart'; @@ -14,7 +15,8 @@ class HorizontalMemberPageController extends CommonDataController { dynamic mid; dynamic wwebid; - Rx userState = LoadingState.loading().obs; + Rx> userState = + LoadingState.loading().obs; RxMap userStat = {}.obs; @override diff --git a/lib/pages/video/detail/member/horizontal_member_page.dart b/lib/pages/video/detail/member/horizontal_member_page.dart index 312a3a1f0..aee43ef56 100644 --- a/lib/pages/video/detail/member/horizontal_member_page.dart +++ b/lib/pages/video/detail/member/horizontal_member_page.dart @@ -348,8 +348,11 @@ class _HorizontalMemberPageState extends State { mid: widget.mid, isFollow: memberInfoModel.isFollowed ?? false, callback: (attribute) { - _controller.userState.value = LoadingState.success( - memberInfoModel..isFollowed = attribute != 0); + (_controller.userState.value + as Success) + .response + .isFollowed = attribute != 0; + _controller.userState.refresh(); }, ); } diff --git a/lib/pages/video/detail/reply_reply/controller.dart b/lib/pages/video/detail/reply_reply/controller.dart index de9263f9d..a4bf26ea0 100644 --- a/lib/pages/video/detail/reply_reply/controller.dart +++ b/lib/pages/video/detail/reply_reply/controller.dart @@ -71,7 +71,7 @@ class VideoReplyReplyController extends ReplyController // reply2Reply // isDialogue.not if (data is DetailListReply) { count.value = data.root.count.toInt(); - if (cursor == null && firstFloor == null) { + if (isRefresh && firstFloor == null) { firstFloor = data.root; } if (id != null) { diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 6aff7c2b5..32ec8cb65 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -498,11 +498,16 @@ class Utils { dynamic res = await DynamicsHttp.dynamicDetail(id: id); if (res['status']) { final ctr = Get.find(tag: 'all'); - List list = ctr.loadingState.value is Success - ? (ctr.loadingState.value as Success).response - : []; - list.insert(0, res['data']); - ctr.loadingState.value = LoadingState.success(list); + if (ctr.loadingState.value is Success) { + List? list = + (ctr.loadingState.value as Success).response; + if (list != null) { + list.insert(0, res['data']); + ctr.loadingState.refresh(); + return; + } + } + ctr.loadingState.value = LoadingState.success([res['data']]); } } } catch (e) {