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.
This commit is contained in:
David Taylor 2024-03-22 13:25:33 +00:00 committed by GitHub
parent 2507bd7b70
commit 04e365f741
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 1 additions and 70 deletions

View File

@ -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");
},
};

View File

@ -314,7 +314,7 @@ en:
search: search:
instructions: |- instructions: |-
_psst_ … Ive hidden a surprise in this topic. If youre up for the challenge, **select the search icon** <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-search.png" width="16" height="16"> at the top right &#8599; to search for it. _psst_ … Ive hidden a surprise in this topic. If youre up for the challenge, **select the search icon** <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-search.png" width="16" height="16"> at the top right &#8599;, choose 'in this topic', then search for it.
Try searching for the term "capy&#8203;bara" in this topic Try searching for the term "capy&#8203;bara" in this topic
hidden_message: |- hidden_message: |-

View File

@ -173,12 +173,6 @@ module DiscourseNarrativeBot
topic = @post.topic topic = @post.topic
post = topic.first_post post = topic.first_post
MessageBus.publish(
"/new_user_narrative/tutorial_search/#{@user.id}",
{},
user_ids: [@user.id],
)
raw = <<~MD raw = <<~MD
#{post.raw} #{post.raw}