FIX: If bookmarking discobot posts, skip the reminder modal (#9505)

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.

diff --git a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6 b/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6
index 45b68ca..6498f50 100644
--- a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6
+++ b/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6
@@ -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;
diff --git a/plugins/discourse-narrative-bot/config/locales/server.en.yml b/plugins/discourse-narrative-bot/config/locales/server.en.yml
index def563e..86d081b 100644
--- a/plugins/discourse-narrative-bot/config/locales/server.en.yml
+++ b/plugins/discourse-narrative-bot/config/locales/server.en.yml
@@ -242,7 +242,7 @@ en:
 
       bookmark:
         instructions: |-
-          If you’d like to learn more, select <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this personal message** selecting "no reminder needed". If you do, there may be a :gift: in your future!
+          If you’d like to learn more, select <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this personal message**. If you do, there may be a :gift: in your future!
         reply: |-
           Excellent! Now you can easily find your way back to our private conversation any time, right from [the bookmarks tab on your profile](%{bookmark_url}). Just select your profile picture at the upper right &#8599;
         not_found: |-

GitHub sha: 5a98869c

This commit appears in #9505 which was merged by martin.