fix: state

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-11 10:51:55 +08:00
parent 5aa5308a50
commit 01b30d942b
10 changed files with 61 additions and 19 deletions

View File

@@ -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<BangumiListItemModel>? 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<BangumiListItemModel> 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;

View File

@@ -36,6 +36,7 @@ abstract class CommonController<R, T> extends GetxController
bool isLoading = false;
late bool isEnd = false;
Rx<LoadingState> get loadingState;
bool? isReply;
Future<LoadingState<R>> customGetData();
@@ -66,6 +67,8 @@ abstract class CommonController<R, T> extends GetxController
isEnd = true;
if (isRefresh) {
loadingState.value = LoadingState<List<T>?>.success(dataList);
} else if (isReply == true) {
loadingState.refresh();
}
isLoading = false;
return;

View File

@@ -35,6 +35,9 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
late Rx<Mode> mode = Mode.MAIN_LIST_HOT.obs;
late bool hasUpTop = false;
@override
bool? get isReply => true;
late final antiGoodsReply = GStorage.antiGoodsReply;
// comment antifraud

View File

@@ -72,7 +72,7 @@ class LiveController
loadingState.refresh();
}
followPage++;
} else {
} else if (isRefresh) {
followListState.value = LoadingState.error(res['msg']);
}
}

View File

@@ -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;
}

View File

@@ -60,7 +60,7 @@ class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
} else {
pair.second.removeAt(index);
}
loadingState.value = LoadingState.success(pair);
loadingState.refresh();
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);

View File

@@ -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<LoadingState> userState = LoadingState.loading().obs;
Rx<LoadingState<MemberInfoModel>> userState =
LoadingState<MemberInfoModel>.loading().obs;
RxMap userStat = {}.obs;
@override

View File

@@ -348,8 +348,11 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
mid: widget.mid,
isFollow: memberInfoModel.isFollowed ?? false,
callback: (attribute) {
_controller.userState.value = LoadingState.success(
memberInfoModel..isFollowed = attribute != 0);
(_controller.userState.value
as Success<MemberInfoModel>)
.response
.isFollowed = attribute != 0;
_controller.userState.refresh();
},
);
}

View File

@@ -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) {