FIX: remove rendering UX from bookmark model (#11765)

Fix for `bookmark.js` model. Most logic was moved to `topic` controller
This commit is contained in:
Krzysztof Kotlarek
2021-01-25 09:35:13 +11:00
committed by GitHub
parent 0a51999a46
commit fcbb6c4143
9 changed files with 223 additions and 167 deletions

View File

@ -13,26 +13,26 @@ function initialize(api) {
},
});
api.modifyClass("model:post", {
toggleBookmark() {
api.modifyClass("controller:topic", {
_togglePostBookmark(post) {
// if we are talking to discobot then any bookmarks should just
// be created without reminder options, to streamline the new user
// narrative.
const discobotUserId = -2;
if (this.user_id === discobotUserId && !this.bookmarked) {
if (post.user_id === discobotUserId && !post.bookmarked) {
return ajax("/bookmarks", {
type: "POST",
data: { post_id: this.id },
data: { post_id: post.id },
}).then((response) => {
this.setProperties({
post.setProperties({
"topic.bookmarked": true,
bookmarked: true,
bookmark_id: response.id,
});
this.appEvents.trigger("post-stream:refresh", { id: this.id });
post.appEvents.trigger("post-stream:refresh", { id: this.id });
});
}
return this._super();
return this._super(post);
},
});