mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:09:18 +08:00
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:
parent
2507bd7b70
commit
04e365f741
|
@ -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");
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -314,7 +314,7 @@ en:
|
||||||
|
|
||||||
search:
|
search:
|
||||||
instructions: |-
|
instructions: |-
|
||||||
_psst_ … I’ve hidden a surprise in this topic. If you’re 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 ↗ to search for it.
|
_psst_ … I’ve hidden a surprise in this topic. If you’re 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 ↗, choose 'in this topic', then search for it.
|
||||||
|
|
||||||
Try searching for the term "capy​bara" in this topic
|
Try searching for the term "capy​bara" in this topic
|
||||||
hidden_message: |-
|
hidden_message: |-
|
||||||
|
|
|
@ -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}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user