mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Can delete custom emoji
This commit is contained in:
@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'package:comunic/helpers/settings_helper.dart';
|
||||
import 'package:comunic/helpers/users_helper.dart';
|
||||
import 'package:comunic/lists/custom_emojies_list.dart';
|
||||
import 'package:comunic/models/custom_emoji.dart';
|
||||
import 'package:comunic/models/new_emoji.dart';
|
||||
import 'package:comunic/models/user.dart';
|
||||
import 'package:comunic/ui/widgets/async_screen_widget.dart';
|
||||
@ -71,6 +72,9 @@ class _CustomEmojiesAccountBodyState extends State<_CustomEmojiesAccountBody> {
|
||||
.map((u) => ListTile(
|
||||
leading: NetworkImageWidget(url: u.url, width: 50),
|
||||
title: Text(u.shortcut),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
onPressed: () => _deleteEmoji(u)),
|
||||
))
|
||||
.toList());
|
||||
}
|
||||
@ -106,6 +110,22 @@ class _CustomEmojiesAccountBodyState extends State<_CustomEmojiesAccountBody> {
|
||||
|
||||
_key.currentState.refresh();
|
||||
}
|
||||
|
||||
/// Ask for confirmation before deleting permanently an emoji
|
||||
void _deleteEmoji(CustomEmoji u) async {
|
||||
try {
|
||||
if (!await showConfirmDialog(
|
||||
context: context,
|
||||
message: tr("Do you really want to delete this custom emoji ?")))
|
||||
return;
|
||||
|
||||
await SettingsHelper.deleteCustomEmoji(u.id);
|
||||
|
||||
_key.currentState.refresh();
|
||||
} catch (e, stack) {
|
||||
print("Could not delete custom emoji! $e\n$stack");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Dialog used to upload new custom emojies
|
||||
|
Reference in New Issue
Block a user