fix: loadingState cast

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-01 13:59:02 +08:00
parent 62a1768307
commit 43977c737b
4 changed files with 26 additions and 20 deletions

View File

@@ -18,11 +18,13 @@ abstract class MultiSelectController extends CommonController {
}
void handleSelect([bool checked = false]) {
List? list = (loadingState.value as Success?)?.response;
if (list.isNullOrEmpty.not) {
loadingState.value = LoadingState.success(
list!.map((item) => item..checked = checked).toList());
checkedCount.value = checked ? list.length : 0;
if (loadingState.value is Success) {
List list = (loadingState.value as Success).response;
if (list.isNotEmpty) {
loadingState.value = LoadingState.success(
list.map((item) => item..checked = checked).toList());
checkedCount.value = checked ? list.length : 0;
}
}
if (checked.not) {
enableMultiSelect.value = false;

View File

@@ -200,8 +200,9 @@ abstract class ReplyController extends CommonController {
savedReplies[key] = null;
if (GlobalData().grpcReply) {
ReplyInfo replyInfo = Utils.replyCast(res);
MainListReply response =
(loadingState.value as Success?)?.response ?? MainListReply();
MainListReply response = loadingState.value is Success
? (loadingState.value as Success).response
: MainListReply();
if (oid != null) {
response.replies.insert(hasUpTop ? 1 : 0, replyInfo);
} else {
@@ -210,8 +211,9 @@ abstract class ReplyController extends CommonController {
count.value += 1;
loadingState.value = LoadingState.success(response);
} else {
ReplyData response =
(loadingState.value as Success?)?.response ?? ReplyData();
ReplyData response = loadingState.value is Success
? (loadingState.value as Success).response
: ReplyData();
response.replies ??= <ReplyItemModel>[];
if (oid != null) {
response.replies