mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: use cascade (#812)
This commit is contained in:
committed by
GitHub
parent
877732e1e7
commit
6f69a45195
@@ -102,9 +102,7 @@ class BangumiController extends CommonListController<
|
||||
followState.value = LoadingState.success(list);
|
||||
followController?.animToTop();
|
||||
} else if (followState.value is Success) {
|
||||
List<BangumiListItemModel> currentList =
|
||||
(followState.value as Success).response;
|
||||
currentList.addAll(list!);
|
||||
final currentList = followState.value.data!..addAll(list!);
|
||||
if (currentList.length >= followCount.value) {
|
||||
followEnd = true;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,7 @@ class BlackListController
|
||||
onConfirm: () async {
|
||||
var result = await VideoHttp.relationMod(mid: mid, act: 6, reSrc: 11);
|
||||
if (result['status']) {
|
||||
List<BlackListItem> list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
total.value -= 1;
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('操作成功');
|
||||
|
||||
@@ -64,8 +64,7 @@ abstract class CommonController<R, T> extends GetxController
|
||||
checkIsEnd(dataList.length);
|
||||
loadingState.value = LoadingState<List<T>?>.success(dataList);
|
||||
} else if (loadingState.value is Success) {
|
||||
List<T> list = (loadingState.value as Success).response;
|
||||
list.addAll(dataList);
|
||||
final list = (loadingState.value.data! as List<T>)..addAll(dataList);
|
||||
checkIsEnd(list.length);
|
||||
loadingState.refresh();
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@ class DynamicsTabController
|
||||
Future onRemove(dynamic dynamicId) async {
|
||||
var res = await MsgHttp.removeDynamic(dynIdStr: dynamicId);
|
||||
if (res['status']) {
|
||||
List<DynamicItemModel> list = (loadingState.value as Success).response;
|
||||
list.removeWhere((item) => item.idStr == dynamicId);
|
||||
loadingState.value.data!.removeWhere((item) => item.idStr == dynamicId);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
|
||||
@@ -38,8 +38,7 @@ class FansController
|
||||
reSrc: 11,
|
||||
);
|
||||
if (res['status']) {
|
||||
List<FansItemModel> list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('移除成功');
|
||||
} else {
|
||||
|
||||
@@ -30,8 +30,7 @@ class FavArticleController extends CommonListController {
|
||||
Future<void> onRemove(index, id) async {
|
||||
final res = await UserHttp.communityAction(opusId: id, action: 4);
|
||||
if (res['status']) {
|
||||
List list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('已取消收藏');
|
||||
} else {
|
||||
|
||||
@@ -57,9 +57,7 @@ class FavPgcController
|
||||
Future bangumiDel(index, seasonId) async {
|
||||
var result = await VideoHttp.bangumiDel(seasonId: seasonId);
|
||||
if (result['status']) {
|
||||
List<BangumiListItemModel> list =
|
||||
(loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
}
|
||||
SmartDialog.showToast(result['msg']);
|
||||
@@ -82,9 +80,8 @@ class FavPgcController
|
||||
try {
|
||||
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
|
||||
if (ctr.loadingState.value is Success) {
|
||||
List<BangumiListItemModel> list =
|
||||
(ctr.loadingState.value as Success).response;
|
||||
list.insertAll(0, updateList.map((item) => item..checked = null));
|
||||
ctr.loadingState.value.data!
|
||||
.insertAll(0, updateList.map((item) => item..checked = null));
|
||||
ctr.loadingState.refresh();
|
||||
ctr.allSelected.value = false;
|
||||
}
|
||||
@@ -108,9 +105,7 @@ class FavPgcController
|
||||
try {
|
||||
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
|
||||
if (ctr.loadingState.value is Success) {
|
||||
List<BangumiListItemModel> list =
|
||||
(ctr.loadingState.value as Success).response;
|
||||
list.insert(0, item);
|
||||
ctr.loadingState.value.data!.insert(0, item);
|
||||
ctr.loadingState.refresh();
|
||||
ctr.allSelected.value = false;
|
||||
}
|
||||
|
||||
@@ -85,10 +85,7 @@ class _FavVideoPageState extends State<FavVideoPage>
|
||||
},
|
||||
);
|
||||
if (res == true) {
|
||||
List<FavFolderItemData> list =
|
||||
(_favController.loadingState.value as Success)
|
||||
.response;
|
||||
list.removeAt(index);
|
||||
_favController.loadingState.value.data!.removeAt(index);
|
||||
_favController.loadingState.refresh();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -45,9 +45,7 @@ class FavSearchController
|
||||
type: type,
|
||||
);
|
||||
if (result['status']) {
|
||||
List<FavDetailItemData> dataList =
|
||||
(loadingState.value as Success).response;
|
||||
dataList.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('取消收藏');
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ class HistorySearchController
|
||||
|
||||
var res = await UserHttp.delHistory([resKid]);
|
||||
if (res['status']) {
|
||||
List historyList = (loadingState.value as Success).response;
|
||||
historyList.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
|
||||
@@ -105,9 +105,7 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
Get.back();
|
||||
var res = await UserHttp.toViewDel(aids: [aid]);
|
||||
if (res['status']) {
|
||||
List<HotVideoItemModel> list =
|
||||
(loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
baseCtr.counts[laterViewType] =
|
||||
baseCtr.counts[laterViewType]! - 1;
|
||||
loadingState.refresh();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_search_controller.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -25,8 +25,7 @@ class LaterSearchController
|
||||
Future toViewDel(BuildContext context, int index, aid) async {
|
||||
var res = await UserHttp.toViewDel(aids: [aid]);
|
||||
if (res['status']) {
|
||||
List<HotVideoItemModel> list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
}
|
||||
SmartDialog.showToast(res['msg']);
|
||||
|
||||
@@ -59,7 +59,8 @@ class LiveController
|
||||
}
|
||||
|
||||
late RxBool isLogin = Accounts.main.isLogin.obs;
|
||||
late Rx<LoadingState> followListState = LoadingState.loading().obs;
|
||||
late Rx<LoadingState<List<LiveFollowingItemModel>?>> followListState =
|
||||
Rx(LoadingState.loading());
|
||||
late int followPage = 1;
|
||||
late bool followEnd = false;
|
||||
late RxInt liveCount = 0.obs;
|
||||
@@ -93,9 +94,8 @@ class LiveController
|
||||
}
|
||||
followListState.value = LoadingState.success(dataList);
|
||||
} else if (followListState.value is Success) {
|
||||
List<LiveFollowingItemModel> list =
|
||||
(followListState.value as Success).response;
|
||||
list.addAll(dataList!);
|
||||
List<LiveFollowingItemModel> list = followListState.value.data!
|
||||
..addAll(dataList!);
|
||||
if (list.length >= liveCount.value) {
|
||||
followEnd = true;
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ class MemberDynamicsController
|
||||
Future onRemove(dynamicId) async {
|
||||
var res = await MsgHttp.removeDynamic(dynIdStr: dynamicId);
|
||||
if (res['status']) {
|
||||
List<DynamicItemModel> list = (loadingState.value as Success).response;
|
||||
list.removeWhere((item) => item.idStr == dynamicId);
|
||||
loadingState.value.data!.removeWhere((item) => item.idStr == dynamicId);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
|
||||
@@ -105,9 +105,8 @@ class MemberSearchController extends GetxController
|
||||
}
|
||||
dynamicState.value = LoadingState.success(items);
|
||||
} else if (dynamicState.value is Success) {
|
||||
List<DynamicItemModel> currentList =
|
||||
(dynamicState.value as Success).response;
|
||||
currentList.addAll(items!);
|
||||
List<DynamicItemModel> currentList = dynamicState.value.data!
|
||||
..addAll(items!);
|
||||
if (currentList.length >= dynamicCount.value) {
|
||||
isEndDynamic = true;
|
||||
}
|
||||
@@ -147,9 +146,8 @@ class MemberSearchController extends GetxController
|
||||
}
|
||||
archiveState.value = LoadingState.success(vlist);
|
||||
} else if (archiveState.value is Success) {
|
||||
List<VListItemModel> currentList =
|
||||
(archiveState.value as Success).response;
|
||||
currentList.addAll(vlist!);
|
||||
List<VListItemModel> currentList = archiveState.value.data!
|
||||
..addAll(vlist!);
|
||||
if (currentList.length >= archiveCount.value) {
|
||||
isEndArchive = true;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,7 @@ class AtMeController extends CommonListController<MsgFeedAtMe, AtMeItems> {
|
||||
try {
|
||||
var res = await MsgHttp.delMsgfeed(2, id);
|
||||
if (res['status']) {
|
||||
List<AtMeItems> list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
|
||||
@@ -46,8 +46,7 @@ class ReplyMeController
|
||||
try {
|
||||
var res = await MsgHttp.delMsgfeed(1, id);
|
||||
if (res['status']) {
|
||||
List<ReplyMeItems> list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
|
||||
@@ -43,8 +43,7 @@ class SysMsgController
|
||||
try {
|
||||
var res = await MsgHttp.delSysMsg(id);
|
||||
if (res['status']) {
|
||||
List<SystemNotifyList> list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
|
||||
@@ -49,9 +49,7 @@ class SubController
|
||||
var res = await UserHttp.cancelSub(
|
||||
id: subFolderItem.id!, type: subFolderItem.type!);
|
||||
if (res['status']) {
|
||||
List<SubFolderItemData> list =
|
||||
(loadingState.value as Success).response;
|
||||
list.remove(subFolderItem);
|
||||
loadingState.value.data!.remove(subFolderItem);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('取消订阅成功');
|
||||
} else {
|
||||
|
||||
@@ -360,12 +360,8 @@ class _VideoReplyReplyPanelState
|
||||
if (res != null) {
|
||||
_savedReplies[key] = null;
|
||||
ReplyInfo replyInfo = RequestUtils.replyCast(res);
|
||||
List<ReplyInfo> list =
|
||||
_videoReplyReplyController.loadingState.value is Success
|
||||
? (_videoReplyReplyController.loadingState.value as Success)
|
||||
.response
|
||||
: <ReplyInfo>[];
|
||||
list.insert(index + 1, replyInfo);
|
||||
_videoReplyReplyController.loadingState.value.dataOrNull
|
||||
?.insert(index + 1, replyInfo);
|
||||
_videoReplyReplyController.count.value += 1;
|
||||
_videoReplyReplyController.loadingState.refresh();
|
||||
if (_videoReplyReplyController.enableCommAntifraud && mounted) {
|
||||
@@ -462,9 +458,7 @@ class _VideoReplyReplyPanelState
|
||||
_onReply(replyItem, index);
|
||||
},
|
||||
onDelete: (subIndex) {
|
||||
List<ReplyInfo> list =
|
||||
(_videoReplyReplyController.loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
_videoReplyReplyController.loadingState.value.data!.removeAt(index);
|
||||
_videoReplyReplyController.count.value -= 1;
|
||||
_videoReplyReplyController.loadingState.refresh();
|
||||
},
|
||||
|
||||
@@ -85,8 +85,7 @@ class WhisperController
|
||||
if (isRefresh) {
|
||||
loadingState.value = LoadingState<List<SessionList>?>.success(dataList);
|
||||
} else if (loadingState.value is Success) {
|
||||
List<SessionList> list = (loadingState.value as Success).response;
|
||||
list.addAll(dataList);
|
||||
loadingState.value.data!.addAll(dataList);
|
||||
loadingState.refresh();
|
||||
}
|
||||
});
|
||||
@@ -103,8 +102,7 @@ class WhisperController
|
||||
Future onRemove(int index, int? talkerId) async {
|
||||
var res = await MsgHttp.removeMsg(talkerId);
|
||||
if (res['status']) {
|
||||
List<SessionList> list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
loadingState.value.data!.removeAt(index);
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user