mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: handle response
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/member.dart';
|
||||
import 'package:PiliPlus/models/space_article/item.dart';
|
||||
import 'package:PiliPlus/models/space_article/data.dart';
|
||||
import 'package:PiliPlus/pages/common/common_controller.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
@@ -25,10 +26,10 @@ class MemberArticleCtr extends CommonController {
|
||||
if (data.item.isNullOrEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
if (currentPage == 1) {
|
||||
count = data.count ?? -1;
|
||||
} else if (loadingState.value is Success) {
|
||||
data.item?.insertAll(0, (loadingState.value as Success).response);
|
||||
count = data.count ?? -1;
|
||||
if (currentPage != 1 && loadingState.value is Success) {
|
||||
data.item ??= <Item>[];
|
||||
data.item!.insertAll(0, (loadingState.value as Success).response);
|
||||
}
|
||||
if ((data.item?.length ?? -1) >= count) {
|
||||
isEnd = true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/member.dart';
|
||||
import 'package:PiliPlus/models/space_archive/data.dart';
|
||||
import 'package:PiliPlus/models/space_archive/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_controller.dart';
|
||||
import 'package:PiliPlus/pages/member/new/content/member_contribute/member_contribute.dart'
|
||||
show ContributeType;
|
||||
@@ -36,7 +37,8 @@ class MemberBangumiCtr extends CommonController {
|
||||
isEnd = true;
|
||||
}
|
||||
if (currentPage != 1 && loadingState.value is Success) {
|
||||
data.item?.insertAll(0, (loadingState.value as Success).response);
|
||||
data.item ??= <Item>[];
|
||||
data.item!.insertAll(0, (loadingState.value as Success).response);
|
||||
}
|
||||
if (data.item!.length >= count) {
|
||||
isEnd = true;
|
||||
|
||||
@@ -59,14 +59,18 @@ class MemberVideoCtr extends CommonController {
|
||||
episodicButton.refresh();
|
||||
next = data.next;
|
||||
aid = data.item?.lastOrNull?.param;
|
||||
isEnd =
|
||||
type == ContributeType.video ? data.hasNext == false : data.next == 0;
|
||||
if (currentPage == 0) {
|
||||
count.value = type == ContributeType.season
|
||||
? (data.item?.length ?? -1)
|
||||
: (data.count ?? -1);
|
||||
} else if (loadingState.value is Success) {
|
||||
data.item?.insertAll(0, (loadingState.value as Success).response);
|
||||
if ((type == ContributeType.video
|
||||
? data.hasNext == false
|
||||
: data.next == 0) ||
|
||||
data.item.isNullOrEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
count.value = type == ContributeType.season
|
||||
? (data.item?.length ?? -1)
|
||||
: (data.count ?? -1);
|
||||
if (currentPage != 0 && loadingState.value is Success) {
|
||||
data.item ??= <Item>[];
|
||||
data.item!.insertAll(0, (loadingState.value as Success).response);
|
||||
}
|
||||
loadingState.value = LoadingState.success(data.item);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user