mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 02:09:54 +08:00
FIX: wasn't able to recover a post
This commit is contained in:
parent
e73556f48f
commit
50487d6122
|
@ -305,7 +305,7 @@ export default Ember.Controller.extend(BufferedContent, {
|
|||
},
|
||||
|
||||
recoverPost(post) {
|
||||
post.get("post_number") === 1 ? this.recoverTopic() : this.recover();
|
||||
post.get("post_number") === 1 ? this.recoverTopic() : post.recover();
|
||||
},
|
||||
|
||||
deletePost(post) {
|
||||
|
|
|
@ -125,35 +125,33 @@ const Post = RestModel.extend({
|
|||
|
||||
// Expands the first post's content, if embedded and shortened.
|
||||
expand() {
|
||||
const self = this;
|
||||
return ajax("/posts/" + this.get('id') + "/expand-embed").then(function(post) {
|
||||
self.set('cooked', "<section class='expanded-embed'>" + post.cooked + "</section>" );
|
||||
return ajax(`/posts/${this.get('id')}/expand-embed`).then(post => {
|
||||
this.set('cooked', `<section class="expanded-embed">${post.cooked}</section>`);
|
||||
});
|
||||
},
|
||||
|
||||
// Recover a deleted post
|
||||
recover() {
|
||||
const post = this,
|
||||
initProperties = post.getProperties('deleted_at', 'deleted_by', 'user_deleted', 'can_delete');
|
||||
const initProperties = this.getProperties('deleted_at', 'deleted_by', 'user_deleted', 'can_delete');
|
||||
|
||||
post.setProperties({
|
||||
this.setProperties({
|
||||
deleted_at: null,
|
||||
deleted_by: null,
|
||||
user_deleted: false,
|
||||
can_delete: false
|
||||
});
|
||||
|
||||
return ajax("/posts/" + (this.get('id')) + "/recover", { type: 'PUT', cache: false }).then(function(data){
|
||||
post.setProperties({
|
||||
return ajax(`/posts/${this.get('id')}/recover`, { type: 'PUT', cache: false }).then(data => {
|
||||
this.setProperties({
|
||||
cooked: data.cooked,
|
||||
raw: data.raw,
|
||||
user_deleted: false,
|
||||
can_delete: true,
|
||||
version: data.version
|
||||
});
|
||||
}).catch(function(error) {
|
||||
}).catch(error => {
|
||||
popupAjaxError(error);
|
||||
post.setProperties(initProperties);
|
||||
this.setProperties(initProperties);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user