From 04e365f7418da937cf2135f1984c2c4666b58903 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 22 Mar 2024 13:25:33 +0000 Subject: [PATCH] FIX: Remove broken narrative-bot search context logic (#26319) In the past we had logic to automatically set the search context to the current topic during the tutorial. This hasn't worked for a long time, and clearly people have still been able to complete the tutorial. In fact, it's probably better for us to teach people how to use the search un-assisted anyway. This commit removes the dead logic, and makes a slight tweak to the copy in the unlikely event of confusion. --- .../initializers/new-user-narrative.js | 63 ------------------- .../config/locales/server.en.yml | 2 +- .../new_user_narrative.rb | 6 -- 3 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js diff --git a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js b/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js deleted file mode 100644 index 2cf2361121b..00000000000 --- a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js +++ /dev/null @@ -1,63 +0,0 @@ -import { withPluginApi } from "discourse/lib/plugin-api"; -import { bind } from "discourse-common/utils/decorators"; - -export default { - name: "new-user-narrative", - - initialize(container) { - const siteSettings = container.lookup("service:site-settings"); - - if (!siteSettings.discourse_narrative_bot_enabled) { - return; - } - - this.messageBus = container.lookup("service:message-bus"); - this.appEvents = container.lookup("service:app-events"); - - withPluginApi("0.8.7", (api) => { - this.currentUser = api.getCurrentUser(); - - if (!this.currentUser) { - return; - } - - api.dispatchWidgetAppEvent( - "site-header", - "header", - "header:search-context-trigger" - ); - - api.attachWidgetAction( - "header", - "headerSearchContextTrigger", - function () { - if (this.site.mobileView) { - this.state.skipSearchContext = false; - } else { - this.state.contextEnabled = true; - this.state.searchContextType = "topic"; - } - } - ); - - this.messageBus.subscribe( - `/new_user_narrative/tutorial_search/${this.currentUser.id}`, - this.onMessage - ); - }); - }, - - teardown() { - if (this.currentUser) { - this.messageBus?.unsubscribe( - `/new_user_narrative/tutorial_search/${this.currentUser.id}`, - this.onMessage - ); - } - }, - - @bind - onMessage() { - this.appEvents.trigger("header:search-context-trigger"); - }, -}; diff --git a/plugins/discourse-narrative-bot/config/locales/server.en.yml b/plugins/discourse-narrative-bot/config/locales/server.en.yml index 2bab753ac5a..b3135aa175d 100644 --- a/plugins/discourse-narrative-bot/config/locales/server.en.yml +++ b/plugins/discourse-narrative-bot/config/locales/server.en.yml @@ -314,7 +314,7 @@ en: search: instructions: |- - _psst_ … I’ve hidden a surprise in this topic. If you’re up for the challenge, **select the search icon** at the top right ↗ to search for it. + _psst_ … I’ve hidden a surprise in this topic. If you’re up for the challenge, **select the search icon** at the top right ↗, choose 'in this topic', then search for it. Try searching for the term "capy​bara" in this topic hidden_message: |- diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb index d31bd7f2646..b601124f84f 100644 --- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb +++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb @@ -173,12 +173,6 @@ module DiscourseNarrativeBot topic = @post.topic post = topic.first_post - MessageBus.publish( - "/new_user_narrative/tutorial_search/#{@user.id}", - {}, - user_ids: [@user.id], - ) - raw = <<~MD #{post.raw}