✨ Delete publisher
This commit is contained in:
parent
c91cf7c813
commit
43e3404dbb
@ -15,7 +15,7 @@ body:json {
|
||||
"client_id": "alphabot",
|
||||
"client_secret": "_uR0sVnHTh",
|
||||
"remark": "新年红包",
|
||||
"amount": 9705,
|
||||
"payee_id": 2
|
||||
"amount": 150,
|
||||
"payee_id": 18
|
||||
}
|
||||
}
|
||||
|
@ -638,5 +638,7 @@
|
||||
"pollVotes": {
|
||||
"one": "{} vote",
|
||||
"other": "{} votes"
|
||||
}
|
||||
},
|
||||
"publisherDelete": "Delete Publisher {}",
|
||||
"publisherDeleteDescription": "Are you sure you want to delete this publisher? This operation is irreversible."
|
||||
}
|
||||
|
@ -637,5 +637,7 @@
|
||||
"pollVotes": {
|
||||
"one": "{} 票",
|
||||
"other": "{} 票"
|
||||
}
|
||||
},
|
||||
"publisherDelete": "删除发布者 {}",
|
||||
"publisherDeleteDescription": "你确定要删除这个发布者吗?该操作不可撤销。"
|
||||
}
|
||||
|
@ -45,6 +45,33 @@ class _PublisherScreenState extends State<PublisherScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _deletePublisher(SnPublisher publisher) async {
|
||||
final confirm = await context.showConfirmDialog(
|
||||
'publisherDelete'.tr(args: ['#${publisher.name}']),
|
||||
'publisherDeleteDescription'.tr(),
|
||||
);
|
||||
if (!confirm) return;
|
||||
|
||||
if (!mounted) return;
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
try {
|
||||
await context
|
||||
.read<SnNetworkProvider>()
|
||||
.client
|
||||
.delete('/cgi/co/publishers/${publisher.name}');
|
||||
if (!mounted) return;
|
||||
context.showSnackbar('publisherDeleted'.tr(args: ['#${publisher.name}']));
|
||||
_publishers.remove(publisher);
|
||||
_fetchPublishers();
|
||||
} catch (err) {
|
||||
if (!mounted) return;
|
||||
context.showErrorDialog(err);
|
||||
} finally {
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -118,6 +145,18 @@ class _PublisherScreenState extends State<PublisherScreen> {
|
||||
});
|
||||
},
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Symbols.delete),
|
||||
const Gap(16),
|
||||
Text('delete').tr(),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
_deletePublisher(publisher);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user