FIX: Remove Bookmark was broken on bookmarks page
This was particularaly bad now that we removed stars :)
This commit is contained in:
parent
f49b11aa34
commit
0de6226a20
|
@ -214,7 +214,13 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (post) {
|
if (post) {
|
||||||
return post.toggleBookmark();
|
return post.toggleBookmark().catch(function(error) {
|
||||||
|
if (error && error.responseText) {
|
||||||
|
bootbox.alert($.parseJSON(error.responseText).errors[0]);
|
||||||
|
} else {
|
||||||
|
bootbox.alert(I18n.t('generic_error'));
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return this.get("model").toggleBookmark();
|
return this.get("model").toggleBookmark();
|
||||||
}
|
}
|
||||||
|
|
|
@ -418,19 +418,9 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
this.toggleProperty("bookmarked");
|
this.toggleProperty("bookmarked");
|
||||||
if (this.get("post_number") === 1) { this.toggleProperty("topic.bookmarked"); }
|
if (this.get("post_number") === 1) { this.toggleProperty("topic.bookmarked"); }
|
||||||
|
|
||||||
return Discourse.ajax("/posts/" + this.get("id") + "/bookmark", {
|
return Discourse.Post.updateBookmark(this.get('id'), this.get('bookmarked')).catch(function() {
|
||||||
type: 'PUT',
|
|
||||||
data: { bookmarked: this.get("bookmarked") }
|
|
||||||
}).then(null, function (error) {
|
|
||||||
|
|
||||||
self.toggleProperty("bookmarked");
|
self.toggleProperty("bookmarked");
|
||||||
if (this.get("post_number") === 1) { this.toggleProperty("topic.bookmarked"); }
|
if (this.get("post_number") === 1) { this.toggleProperty("topic.bookmarked"); }
|
||||||
|
|
||||||
if (error && error.responseText) {
|
|
||||||
bootbox.alert($.parseJSON(error.responseText).errors[0]);
|
|
||||||
} else {
|
|
||||||
bootbox.alert(I18n.t('generic_error'));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -461,6 +451,13 @@ Discourse.Post.reopenClass({
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateBookmark: function(postId, bookmarked) {
|
||||||
|
return Discourse.ajax("/posts/" + postId + "/bookmark", {
|
||||||
|
type: 'PUT',
|
||||||
|
data: { bookmarked: bookmarked }
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
deleteMany: function(selectedPosts, selectedReplies) {
|
deleteMany: function(selectedPosts, selectedReplies) {
|
||||||
return Discourse.ajax("/posts/destroy_many", {
|
return Discourse.ajax("/posts/destroy_many", {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
|
|
|
@ -26,18 +26,18 @@ export default Discourse.Route.extend(ShowFooter, {
|
||||||
},
|
},
|
||||||
|
|
||||||
removeBookmark: function(userAction) {
|
removeBookmark: function(userAction) {
|
||||||
var self = this;
|
var user = this.modelFor('user');
|
||||||
Discourse.Post.bookmark(userAction.get('post_id'), false)
|
Discourse.Post.updateBookmark(userAction.get('post_id'), false)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// remove the user action from the stream
|
// remove the user action from the stream
|
||||||
self.modelFor("user").get("stream").remove(userAction);
|
user.get('stream').remove(userAction);
|
||||||
// update the counts
|
// update the counts
|
||||||
self.modelFor("user").get("stats").forEach(function (stat) {
|
user.get('stats').forEach(function (stat) {
|
||||||
if (stat.get("action_type") === userAction.action_type) {
|
if (stat.get("action_type") === userAction.action_type) {
|
||||||
stat.decrementProperty("count");
|
stat.decrementProperty("count");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ export default Discourse.View.extend(StringBuffer, {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(post.get("bookmarked")){
|
if (post.get("bookmarked")) {
|
||||||
hiddenButtons.removeObject("bookmark");
|
hiddenButtons.removeObject("bookmark");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue