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;