1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 22:39:22 +00:00

Can delete group logo

This commit is contained in:
Pierre HUBERT 2020-05-02 09:15:02 +02:00
parent 4cb672cb16
commit 9646cb7a70
2 changed files with 29 additions and 1 deletions

View File

@ -237,6 +237,12 @@ class GroupsHelper {
.addBytesFile("logo", BytesFile("logo.png", bytes))
.execWithFilesAndThrow();
/// Delete group logo
static Future<void> deleteLogo(int groupID) async =>
await APIRequest(uri: "groups/delete_logo", needLogin: true)
.addInt("id", groupID)
.execWithThrow();
/// Turn an API entry into a group object
Group _getGroupFromAPI(Map<String, dynamic> map) {
return Group(

View File

@ -261,7 +261,13 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
SettingsTile(
title: tr("Generate a new random logo"),
onTap: _generateRandomLogo,
)
),
// Delete current logo
SettingsTile(
title: tr("Delete logo"),
onTap: _deleteLogo,
),
],
);
}
@ -294,4 +300,20 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
await GroupsHelper.uploadNewLogo(_groupSettings.id, bytes);
_key.currentState.refresh();
}
/// Delete previous group logo
void _deleteLogo() async {
try {
if (!await showConfirmDialog(
context: context,
message: tr("Do you really want to delete the logo of this group ?")))
return;
await GroupsHelper.deleteLogo(_groupSettings.id);
_key.currentState.refresh();
} catch (e, s) {
print("Could not delete group logo! $e\n$s");
showSimpleSnack(context, tr("Could not delete group logo!"));
}
}
}