mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 22:46:01 +08:00
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:

committed by
GitHub

parent
0a51999a46
commit
fcbb6c4143
@ -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);
|
||||
},
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user