Delete avatar

This commit is contained in:
Natsumi
2021-03-24 23:16:39 +13:00
parent 916d339817
commit 267ce200f6
2 changed files with 57 additions and 5 deletions

View File

@@ -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;
}
}
});

View File

@@ -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