Skip to content

Commit 20e70d0

Browse files
authored
DEV: adds a topic level bookmark toggle (#14471)
1 parent 4285706 commit 20e70d0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/assets/javascripts/discourse/app/controllers/topic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,7 @@ export default Controller.extend(bufferedProperty("model"), {
12171217
onAfterSave: () => {
12181218
this.model.set("bookmarked", true);
12191219
this.model.incrementProperty("bookmarksWereChanged");
1220+
this.appEvents.trigger("topic:bookmark-toggled");
12201221
},
12211222
});
12221223
},

app/assets/javascripts/discourse/app/models/topic.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,13 @@ const Topic = RestModel.extend({
384384
}
385385
this.set(
386386
"bookmarks",
387-
this.bookmarks.filter((bookmark) => bookmark.id !== id)
387+
this.bookmarks.filter((bookmark) => {
388+
if (bookmark.id === id && bookmark.for_topic) {
389+
this.appEvents.trigger("topic:bookmark-toggled");
390+
}
391+
392+
return bookmark.id !== id;
393+
})
388394
);
389395
this.set("bookmarked", this.bookmarks.length);
390396
this.incrementProperty("bookmarksWereChanged");

0 commit comments

Comments
 (0)