opt: common ctr

opt: state

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-11 12:21:42 +08:00
parent 5bff1747e6
commit 574bf861f0
129 changed files with 1065 additions and 1058 deletions

View File

@@ -10,6 +10,8 @@ class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
int cursor = -1;
int cursorTime = -1;
bool isEnd = false;
@override
void onInit() {
super.onInit();
@@ -27,14 +29,12 @@ class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
cursorTime = data.total?.cursor?.time ?? -1;
List<LikeMeItems> latest = data.latest?.items ?? [];
List<LikeMeItems> total = data.total?.items ?? [];
if (currentPage != 1 && loadingState.value is Success) {
Pair<List<LikeMeItems>, List<LikeMeItems>> pair =
(loadingState.value as Success).response;
if (!isRefresh && loadingState.value is Success) {
Pair<List<LikeMeItems>, List<LikeMeItems>> pair = loadingState.value.data;
latest.insertAll(0, pair.first);
total.insertAll(0, pair.second);
}
loadingState.value =
LoadingState.success(Pair(first: latest, second: total));
loadingState.value = Success(Pair(first: latest, second: total));
return true;
}

View File

@@ -69,10 +69,9 @@ class _LikeMePageState extends State<LikeMePage> {
return const MsgFeedTopSkeleton();
},
),
Success() => () {
Success(:var response) => () {
final theme = Theme.of(context);
Pair<List<LikeMeItems>, List<LikeMeItems>> pair =
loadingState.response;
Pair<List<LikeMeItems>, List<LikeMeItems>> pair = response;
List<LikeMeItems> latest = pair.first;
List<LikeMeItems> total = pair.second;
if (latest.isNotEmpty || total.isNotEmpty) {
@@ -143,8 +142,8 @@ class _LikeMePageState extends State<LikeMePage> {
}
return HttpError(onReload: _likeMeController.onReload);
}(),
Error() => HttpError(
errMsg: loadingState.errMsg,
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _likeMeController.onReload,
),
};