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

@@ -36,16 +36,17 @@ class AtMeController extends CommonListController<MsgAtData, MsgAtItem> {
Future<LoadingState<MsgAtData>> customGetData() =>
MsgHttp.msgFeedAtMe(cursor: cursor, cursorTime: cursorTime);
Future<void> onRemove(dynamic id, int index) async {
@pragma('vm:notify-debugger-on-exception')
Future<void> onRemove(Object id, int index) async {
try {
var res = await MsgHttp.delMsgfeed(2, id);
if (res['status']) {
if (res.isSuccess) {
loadingState
..value.data!.removeAt(index)
..refresh();
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
} catch (_) {}
}

View File

@@ -96,7 +96,7 @@ class _AtMePageState extends State<AtMePage> {
void onLongPress() => showConfirmDialog(
context: context,
title: '确定删除该通知?',
onConfirm: () => _atMeController.onRemove(item.id, index),
onConfirm: () => _atMeController.onRemove(item.id!, index),
);
return ListTile(
safeArea: true,

View File

@@ -66,7 +66,7 @@ class LikeMeController
Future<void> onRemove(dynamic id, int index, bool isLatest) async {
try {
var res = await MsgHttp.delMsgfeed(0, id);
if (res['status']) {
if (res.isSuccess) {
Pair<List<MsgLikeItem>, List<MsgLikeItem>> pair =
loadingState.value.data;
if (isLatest) {
@@ -77,20 +77,23 @@ class LikeMeController
loadingState.refresh();
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
} catch (_) {}
}
Future<void> onSetNotice(MsgLikeItem item, bool isNotice) async {
int noticeState = isNotice ? 1 : 0;
var res = await MsgHttp.msgSetNotice(id: item.id, noticeState: noticeState);
if (res['status']) {
var res = await MsgHttp.msgSetNotice(
id: item.id!,
noticeState: noticeState,
);
if (res.isSuccess) {
item.noticeState = noticeState;
loadingState.refresh();
SmartDialog.showToast('操作成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
}

View File

@@ -40,13 +40,13 @@ class ReplyMeController
Future<void> onRemove(dynamic id, int index) async {
try {
var res = await MsgHttp.delMsgfeed(1, id);
if (res['status']) {
if (res.isSuccess) {
loadingState
..value.data!.removeAt(index)
..refresh();
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
} catch (_) {}
}

View File

@@ -37,13 +37,13 @@ class SysMsgController
Future<void> onRemove(dynamic id, int index) async {
try {
var res = await MsgHttp.delSysMsg(id);
if (res['status']) {
if (res.isSuccess) {
loadingState
..value.data!.removeAt(index)
..refresh();
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
} catch (_) {}
}