diff --git a/html/src/app.js b/html/src/app.js index 178f0eac..a7de2c46 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -1734,6 +1734,21 @@ speechSynthesis.getVoices(); this.$emit('USER:CURRENT', args); }); + API.$on('AVATAR:DELETE', function (args) { + var { json } = args; + this.cachedAvatars.delete(json._id); + if ($app.userDialog.id === json.authorId) { + var map = new Map(); + for (var ref of this.cachedAvatars.values()) { + if (ref.authorId === json.authorId) { + map.set(ref.id, ref); + } + } + var array = Array.from(map.values()); + $app.setUserDialogAvatars(array); + } + }); + API.applyAvatar = function (json) { var ref = this.cachedAvatars.get(json.id); if (typeof ref === 'undefined') { @@ -1869,6 +1884,11 @@ speechSynthesis.getVoices(); }); }; + /* + params: { + avatarId: string + } + */ API.selectFallbackAvatar = function (params) { return this.call(`avatars/${params.avatarId}/selectfallback`, { method: 'PUT', @@ -1883,6 +1903,25 @@ speechSynthesis.getVoices(); }); }; + /* + params: { + avatarId: string + } + */ + API.deleteAvatar = function (params) { + return this.call(`avatars/${params.avatarId}`, { + method: 'DELETE', + params + }).then((json) => { + var args = { + json, + params + }; + this.$emit('AVATAR:DELETE', args); + return args; + }); + }; + // API: Notification API.cachedNotifications = new Map(); @@ -8306,11 +8345,23 @@ speechSynthesis.getVoices(); message: 'Avatar updated to private', type: 'success' }); - return args; - }); - break; - default: - break; + return args; + }); + break; + case 'Delete': + API.deleteAvatar({ + avatarId: D.id + }).then((args) => { + this.$message({ + message: 'Avatar deleted', + type: 'success' + }); + D.visible = false; + return args; + }); + break; + default: + break; } } }); diff --git a/html/src/index.pug b/html/src/index.pug index 2cd903a8..d4ff92a5 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -1165,6 +1165,7 @@ html el-dropdown-item(v-else icon="el-icon-user" command="Make Public" divided) Make Public el-dropdown-item(icon="el-icon-edit" command="Rename") Rename el-dropdown-item(icon="el-icon-edit" command="Change Description") Change Description + el-dropdown-item(icon="el-icon-user" command="Delete" style="color:#F56C6C" divided) Delete el-tabs el-tab-pane(label="Info") .x-friend-list