setting release status on own avatars (closes #46)

This commit is contained in:
pypy
2020-07-12 18:13:16 +09:00
parent edd2437079
commit 4fe74d2dd0
2 changed files with 57 additions and 0 deletions

View File

@@ -1640,6 +1640,16 @@ CefSharp.BindObjectAsync(
}
});
API.$on('AVATAR:SAVE', function (args) {
var { json } = args;
this.$emit('AVATAR', {
json,
params: {
avatarId: json.id
}
});
});
API.$on('AVATAR:SELECT', function (args) {
this.$emit('USER:CURRENT', args);
});
@@ -1740,6 +1750,26 @@ CefSharp.BindObjectAsync(
});
};
/*
params: {
id: string
releaseStatus: string ('public','private'),
}
*/
API.saveAvatar = function (params) {
return this.call(`avatars/${params.id}`, {
method: 'PUT',
params
}).then((json) => {
var args = {
json,
params
};
this.$emit('AVATAR:SAVE', args);
return args;
});
};
/*
params: {
avatarId: string
@@ -6567,6 +6597,30 @@ CefSharp.BindObjectAsync(
return args;
});
break;
case 'Make Public':
API.saveAvatar({
id: D.id,
releaseStatus: 'public'
}).then((args) => {
this.$message({
message: 'Avatar updated to public',
type: 'success'
});
return args;
});;
break;
case 'Make Private':
API.saveAvatar({
id: D.id,
releaseStatus: 'private'
}).then((args) => {
this.$message({
message: 'Avatar updated to private',
type: 'success'
});
return args;
});;
break;
default:
break;
}

View File

@@ -904,6 +904,9 @@ html
el-button(type="default" icon="el-icon-more" circle)
el-dropdown-menu(#default="dropdown")
el-dropdown-item(icon="el-icon-check" command="Select Avatar") Select Avatar
template(v-if="avatarDialog.ref.authorId === API.currentUser.id")
el-dropdown-item(v-if="avatarDialog.ref.releaseStatus === 'public'" icon="el-icon-user-solid" command="Make Private" divided) Make Private
el-dropdown-item(v-else icon="el-icon-user" command="Make Public" divided) Make Public
el-tabs
el-tab-pane(label="Info")
.x-friend-list