opt: LoadingState (#1776)

This commit is contained in:
My-Responsitories
2025-12-13 12:43:32 +08:00
committed by GitHub
parent 3741fe54ff
commit 17883eb77e
82 changed files with 832 additions and 887 deletions

View File

@@ -25,15 +25,15 @@ class FavArticleController
Future<LoadingState<FavArticleData>> customGetData() =>
FavHttp.favArticle(page: page);
Future<void> onRemove(int index, String? id) async {
Future<void> onRemove(int index, String id) async {
final res = await FavHttp.communityAction(opusId: id, action: 4);
if (res['status']) {
if (res.isSuccess) {
loadingState
..value.data!.removeAt(index)
..refresh();
SmartDialog.showToast('已取消收藏');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
}

View File

@@ -66,7 +66,7 @@ class _FavArticlePageState extends State<FavArticlePage>
context: context,
title: '确定取消收藏?',
onConfirm: () =>
_favArticleController.onRemove(index, item.opusId),
_favArticleController.onRemove(index, item.opusId!),
),
);
},

View File

@@ -26,15 +26,15 @@ class FavCheeseController
Future<LoadingState<SpaceCheeseData>> customGetData() =>
FavHttp.favPugv(mid: mid, page: page);
Future<void> onRemove(int index, int? sid) async {
Future<void> onRemove(int index, int sid) async {
var res = await FavHttp.delFavPugv(sid);
if (res['status']) {
if (res.isSuccess) {
loadingState
..value.data!.removeAt(index)
..refresh();
SmartDialog.showToast('已取消收藏');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
}

View File

@@ -68,7 +68,7 @@ class _FavCheesePageState extends State<FavCheesePage>
context: context,
title: '确定取消收藏该课堂?',
onConfirm: () =>
_controller.onRemove(index, item.seasonId),
_controller.onRemove(index, item.seasonId!),
),
);
},

View File

@@ -42,11 +42,11 @@ class FavNoteController
.map((item) => isPublish ? item.cvid : item.noteId)
.join(','),
);
if (res['status']) {
if (res.isSuccess) {
afterDelete(removeList);
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}

View File

@@ -53,12 +53,14 @@ class FavPgcController
// 取消追番
Future<void> pgcDel(int index, seasonId) async {
var result = await VideoHttp.pgcDel(seasonId: seasonId);
if (result['status']) {
if (result case Success(:final response)) {
loadingState
..value.data!.removeAt(index)
..refresh();
SmartDialog.showToast(response);
} else {
result.toast();
}
SmartDialog.showToast(result['msg']);
}
@override
@@ -72,7 +74,7 @@ class FavPgcController
seasonId: removeList.map((item) => item.seasonId).join(','),
status: followStatus,
);
if (res['status']) {
if (res case Success(:final response)) {
try {
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
if (ctr.loadingState.value.isSuccess) {
@@ -88,8 +90,10 @@ class FavPgcController
if (kDebugMode) debugPrint('fav pgc onUpdate: $e');
}
afterDelete(removeList);
SmartDialog.showToast(response);
} else {
res.toast();
}
SmartDialog.showToast(res['msg']);
}
Future<void> onUpdate(int index, int followStatus, int? seasonId) async {
@@ -97,7 +101,7 @@ class FavPgcController
seasonId: seasonId.toString(),
status: followStatus,
);
if (result['status']) {
if (result case Success(:final response)) {
List<FavPgcItemModel> list = loadingState.value.data!;
final item = list.removeAt(index);
loadingState.refresh();
@@ -112,7 +116,9 @@ class FavPgcController
} catch (e) {
if (kDebugMode) debugPrint('fav pgc pgcUpdate: $e');
}
SmartDialog.showToast(response);
} else {
result.toast();
}
SmartDialog.showToast(result['msg']);
}
}

View File

@@ -38,15 +38,15 @@ class FavTopicController
Future<LoadingState<FavTopicData>> customGetData() =>
FavHttp.favTopic(page: page);
Future<void> onRemove(int index, int? id) async {
Future<void> onRemove(int index, int id) async {
var res = await FavHttp.delFavTopic(id);
if (res['status']) {
if (res.isSuccess) {
loadingState
..value.data!.removeAt(index)
..refresh();
SmartDialog.showToast('已取消收藏');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
}

View File

@@ -84,7 +84,7 @@ class _FavTopicPageState extends State<FavTopicPage>
void onLongPress() => showConfirmDialog(
context: context,
title: '确定取消收藏?',
onConfirm: () => _controller.onRemove(index, item.id),
onConfirm: () => _controller.onRemove(index, item.id!),
);
return Material(