mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
opt: LoadingState (#1776)
This commit is contained in:
committed by
GitHub
parent
3741fe54ff
commit
17883eb77e
@@ -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 (_) {}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 (_) {}
|
||||
}
|
||||
|
||||
@@ -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 (_) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user