diff --git a/assets/css/components/conversations/windows.css b/assets/css/components/conversations/windows.css
index 5808217a..cc55bd5a 100644
--- a/assets/css/components/conversations/windows.css
+++ b/assets/css/components/conversations/windows.css
@@ -95,6 +95,11 @@
transform: translate(0, 0);
}
+#conversationsElem .conversation-settings-pane .conversation-image-settings .btn {
+ margin: 5px;
+ width: 100%;
+}
+
/**
* Conversations messages
*/
diff --git a/assets/js/components/conversations/chatWindows.js b/assets/js/components/conversations/chatWindows.js
index 159792c0..61788269 100644
--- a/assets/js/components/conversations/chatWindows.js
+++ b/assets/js/components/conversations/chatWindows.js
@@ -729,16 +729,17 @@ const ConvChatWindow = {
const convImageSection = createElem2({
appendTo: settingsForm.rootElem,
type: "div",
+ class: "conversation-image-settings",
innerHTML: "
" + tr("Conversation image") + ":
" }) - // Upload a new image + // Upload a new logo const newConvImagebutton = createElem2({ appendTo: convImageSection, type: "button", class: "btn btn-default", - innerHTML: tr("Upload a new conversation image") + innerHTML: tr("Upload a new conversation logo") }); newConvImagebutton.addEventListener("click", async e => { @@ -751,6 +752,32 @@ const ConvChatWindow = { notify(tr("Failed to change conversation image!"), "danger"); } }) + + + // Delete current image + if (conversation.infos.logo != null) { + const deleteConvImage = createElem2({ + appendTo: convImageSection, + type: "button", + class: "btn btn-danger", + innerHTML: tr("Delete current logo") + }); + + deleteConvImage.addEventListener("click", async e => { + e.preventDefault(); + try { + if (!await showConfirmDialog(tr("Do you really want to delete this image ?"))) + return; + + await ConversationsInterface.deleteConversationImage(conversation.infos.id); + ConvChatWindow.reload(conversation) + } catch(e) { + console.error(e); + notify(tr("Failed to remove conversation image!"), "danger"); + } + }) + } + } }, diff --git a/assets/js/components/conversations/interface.js b/assets/js/components/conversations/interface.js index c63b415b..ae537db5 100644 --- a/assets/js/components/conversations/interface.js +++ b/assets/js/components/conversations/interface.js @@ -282,6 +282,17 @@ const ConversationsInterface = { await APIClient.execFormData("conversations/change_image", fd, true) }, + /** + * Delete current conversation image + * + * @param {number} convID Target converstain ID + */ + deleteConversationImage: async function(convID) { + await api("conversations/delete_image", { + convID: convID + }, true) + }, + /** * Refresh a conversation *