✨ Allow to delete contact methods
This commit is contained in:
@ -42,6 +42,24 @@ class _AccountContactMethodState extends State<AccountContactMethod> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _deleteContactMethod(SnAccountContact contact) async {
|
||||
final confirm = await context.showConfirmDialog(
|
||||
'accountContactMethodsDelete'.tr(),
|
||||
'accountContactMethodsDeleteDescription'.tr(args: [contact.content]),
|
||||
);
|
||||
if (!confirm || !mounted) return;
|
||||
|
||||
try {
|
||||
final sn = context.read<SnNetworkProvider>();
|
||||
await sn.client.delete('/cgi/id/users/me/contacts/${contact.id}');
|
||||
if (!mounted) return;
|
||||
await _fetchContactMethods();
|
||||
} catch (err) {
|
||||
if (!mounted) return;
|
||||
context.showErrorDialog(err);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -118,7 +136,7 @@ class _AccountContactMethodState extends State<AccountContactMethod> {
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Symbols.edit),
|
||||
const Gap(8),
|
||||
const Gap(16),
|
||||
Text('edit').tr(),
|
||||
],
|
||||
),
|
||||
@ -135,6 +153,18 @@ class _AccountContactMethodState extends State<AccountContactMethod> {
|
||||
});
|
||||
},
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Symbols.delete),
|
||||
const Gap(16),
|
||||
Text('delete'.tr()),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
_deleteContactMethod(method);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user