mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FIX: If bookmarking discobot posts, skip the reminder modal (#9505)
This is to streamline the new user narrative. only works when creating the bookmark, if editing/deleting the modal is shown. This is done via the plugin initializer.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
function initialize(api) {
|
||||
const messageBus = api.container.lookup("message-bus:main");
|
||||
@ -12,6 +13,29 @@ function initialize(api) {
|
||||
}
|
||||
});
|
||||
|
||||
api.modifyClass("model:post", {
|
||||
toggleBookmarkWithReminder() {
|
||||
// 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_with_reminder) {
|
||||
return ajax("/bookmarks", {
|
||||
type: "POST",
|
||||
data: { post_id: this.id }
|
||||
}).then(response => {
|
||||
this.setProperties({
|
||||
"topic.bookmarked": true,
|
||||
bookmarked_with_reminder: true,
|
||||
bookmark_id: response.id
|
||||
});
|
||||
this.appEvents.trigger("post-stream:refresh", { id: this.id });
|
||||
});
|
||||
}
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
|
||||
api.attachWidgetAction("header", "headerSearchContextTrigger", function() {
|
||||
if (this.site.mobileView) {
|
||||
this.state.skipSearchContext = false;
|
||||
|
Reference in New Issue
Block a user