Can request to delete an emoji

This commit is contained in:
Pierre HUBERT 2020-04-03 18:43:23 +02:00
parent d717b6f2f7
commit 527f0a838c
2 changed files with 43 additions and 4 deletions

View File

@ -4,7 +4,7 @@
* @author Pierre HUBERT
*/
ComunicWeb.components.settings.interface = {
const SettingsInterface = {
/**
* Get general account settings
@ -175,4 +175,17 @@ ComunicWeb.components.settings.interface = {
})
})
},
}
/**
* Delete a custom emoji
*
* @param {Number} id The ID of the emoji to delete
*/
deleteEmoji: async function(id) {
await api("settings/delete_custom_emoji", {
emojiID: id
}, true);
},
}
ComunicWeb.components.settings.interface = SettingsInterface;

View File

@ -72,10 +72,36 @@ class EmojiesSection {
line.innerHTML += "<td><img class='e' src='"+e.url+"' /></td>" +
"<td>"+e.shorcut+"</td>"
"<td>"+e.shorcut+"</td><td></td>"
// Add delete button
const deleteBtnTarget = line.querySelector("td:last-of-type")
const deleteButtonLink = createElem2({
appendTo: deleteBtnTarget,
type: "a",
innerHTML: "<i class='fa fa-trash'></i>"
});
deleteButtonLink.addEventListener("click", () => {
ComunicWeb.common.messages.confirm("Do you really want to delete this emoji ?", async (confirm) => {
if(!confirm)
return;
try {
await SettingsInterface.deleteEmoji(e.id)
this.RefreshList(target);
} catch(e) {
console.error(e);
notify("Could not delete emoji!", "danger")
}
})
})
}
} catch (error) {
@ -179,7 +205,7 @@ class EmojiesSection {
fd.append("shorcut", shorcut)
fd.append("image", associatedImage.files[0])
await ComunicWeb.components.settings.interface.uploadEmoji(fd)
await SettingsInterface.uploadEmoji(fd)
cb()