mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Can delete custom emoji
This commit is contained in:
parent
5d432a5f87
commit
3cf9ee39d0
@ -125,7 +125,7 @@ class SettingsHelper {
|
|||||||
.exec())
|
.exec())
|
||||||
.isOK;
|
.isOK;
|
||||||
|
|
||||||
/// Upload a new emoji
|
/// Upload a new custom emoji
|
||||||
static Future<void> uploadNewCustomEmoji(NewEmoji newEmoji) async =>
|
static Future<void> uploadNewCustomEmoji(NewEmoji newEmoji) async =>
|
||||||
(await APIRequest(
|
(await APIRequest(
|
||||||
uri: "settings/upload_custom_emoji",
|
uri: "settings/upload_custom_emoji",
|
||||||
@ -134,4 +134,13 @@ class SettingsHelper {
|
|||||||
.addFile("image", newEmoji.image)
|
.addFile("image", newEmoji.image)
|
||||||
.execWithFiles())
|
.execWithFiles())
|
||||||
.assertOk();
|
.assertOk();
|
||||||
|
|
||||||
|
/// Delete a custom emoji
|
||||||
|
///
|
||||||
|
/// Throws in case of failure
|
||||||
|
static Future<void> deleteCustomEmoji(int emojiID) async =>
|
||||||
|
(await APIRequest(uri: "settings/delete_custom_emoji", needLogin: true)
|
||||||
|
.addInt("emojiID", emojiID)
|
||||||
|
.exec())
|
||||||
|
.assertOk();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
import 'package:comunic/helpers/settings_helper.dart';
|
import 'package:comunic/helpers/settings_helper.dart';
|
||||||
import 'package:comunic/helpers/users_helper.dart';
|
import 'package:comunic/helpers/users_helper.dart';
|
||||||
import 'package:comunic/lists/custom_emojies_list.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/new_emoji.dart';
|
||||||
import 'package:comunic/models/user.dart';
|
import 'package:comunic/models/user.dart';
|
||||||
import 'package:comunic/ui/widgets/async_screen_widget.dart';
|
import 'package:comunic/ui/widgets/async_screen_widget.dart';
|
||||||
@ -71,6 +72,9 @@ class _CustomEmojiesAccountBodyState extends State<_CustomEmojiesAccountBody> {
|
|||||||
.map((u) => ListTile(
|
.map((u) => ListTile(
|
||||||
leading: NetworkImageWidget(url: u.url, width: 50),
|
leading: NetworkImageWidget(url: u.url, width: 50),
|
||||||
title: Text(u.shortcut),
|
title: Text(u.shortcut),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(Icons.delete),
|
||||||
|
onPressed: () => _deleteEmoji(u)),
|
||||||
))
|
))
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
@ -106,6 +110,22 @@ class _CustomEmojiesAccountBodyState extends State<_CustomEmojiesAccountBody> {
|
|||||||
|
|
||||||
_key.currentState.refresh();
|
_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
|
/// Dialog used to upload new custom emojies
|
||||||
|
Loading…
Reference in New Issue
Block a user