DEV: adds a topic level bookmark toggle (#14471)

This commit is contained in:
Joffrey JAFFEUX 2021-10-06 11:53:57 +02:00 committed by GitHub
parent 4285706d97
commit 20e70d0ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -1217,6 +1217,7 @@ export default Controller.extend(bufferedProperty("model"), {
onAfterSave: () => {
this.model.set("bookmarked", true);
this.model.incrementProperty("bookmarksWereChanged");
this.appEvents.trigger("topic:bookmark-toggled");
},
});
},

View File

@ -384,7 +384,13 @@ const Topic = RestModel.extend({
}
this.set(
"bookmarks",
this.bookmarks.filter((bookmark) => bookmark.id !== id)
this.bookmarks.filter((bookmark) => {
if (bookmark.id === id && bookmark.for_topic) {
this.appEvents.trigger("topic:bookmark-toggled");
}
return bookmark.id !== id;
})
);
this.set("bookmarked", this.bookmarks.length);
this.incrementProperty("bookmarksWereChanged");