mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +00:00
Can remove conversation logo
This commit is contained in:
parent
642f5e11fc
commit
99ae726c0a
@ -109,6 +109,14 @@ class ConversationsHelper {
|
|||||||
.addBytesFile("file", file)
|
.addBytesFile("file", file)
|
||||||
.execWithFilesAndThrow();
|
.execWithFilesAndThrow();
|
||||||
|
|
||||||
|
/// Remove conversation logo
|
||||||
|
///
|
||||||
|
/// Throws in case of failure
|
||||||
|
static Future<void> removeLogo(int convID) async =>
|
||||||
|
await APIRequest.withLogin("conversations/delete_image")
|
||||||
|
.addInt("convID", convID)
|
||||||
|
.execWithThrow();
|
||||||
|
|
||||||
/// Delete a conversation specified by its [id]
|
/// Delete a conversation specified by its [id]
|
||||||
Future<void> deleteConversation(int id) async =>
|
Future<void> deleteConversation(int id) async =>
|
||||||
await APIRequest.withLogin("conversations/delete")
|
await APIRequest.withLogin("conversations/delete")
|
||||||
|
@ -175,9 +175,6 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// Conversation image
|
|
||||||
isUpdating ? _buildConversationImageWidget() : Container(),
|
|
||||||
|
|
||||||
// Add a member to the conversation
|
// Add a member to the conversation
|
||||||
PickUserWidget(
|
PickUserWidget(
|
||||||
resetOnChoose: true,
|
resetOnChoose: true,
|
||||||
@ -190,6 +187,9 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
Column(
|
Column(
|
||||||
children: _members.map((f) => _buildMemberTile(f)).toList(),
|
children: _members.map((f) => _buildMemberTile(f)).toList(),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Conversation image
|
||||||
|
isUpdating ? _buildConversationImageWidget() : Container(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -335,9 +335,22 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
: CachedNetworkImage(imageUrl: _image),
|
: CachedNetworkImage(imageUrl: _image),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
isAdmin
|
isAdmin
|
||||||
? OutlineButton(
|
? Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
OutlineButton(
|
||||||
onPressed: _uploadNewLogo,
|
onPressed: _uploadNewLogo,
|
||||||
child: Text(tr("Change logo")),
|
child: Text(tr("Change logo")),
|
||||||
|
),
|
||||||
|
SizedBox(width: 5),
|
||||||
|
_image == null
|
||||||
|
? Container()
|
||||||
|
: OutlineButton(
|
||||||
|
onPressed: _deleteLogo,
|
||||||
|
child: Text(tr("Delete logo")),
|
||||||
|
highlightedBorderColor: Colors.red,
|
||||||
|
),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
: Container(),
|
: Container(),
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
@ -366,4 +379,20 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
snack(context, tr("Failed to change conversation logo !"));
|
snack(context, tr("Failed to change conversation logo !"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Delete conversation logo
|
||||||
|
Future<void> _deleteLogo() async {
|
||||||
|
try {
|
||||||
|
if (!await showConfirmDialog(
|
||||||
|
context: context,
|
||||||
|
message: tr("Do you really want to delete this logo?"))) return;
|
||||||
|
|
||||||
|
await ConversationsHelper.removeLogo(_conversation.id);
|
||||||
|
|
||||||
|
setState(() => _image = null);
|
||||||
|
} catch (e, s) {
|
||||||
|
logError(e, s);
|
||||||
|
snack(context, tr("Failed to remove conversation logo!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user