mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 23:04:42 +08:00
5c9bb73ffe
1. Originally the feature did "Scroll to new posts when user is near bottom of PM" (74e1889924
) 2. Then that feature was limited to "Only scroll to posts that are not your own in PMs." (4a26561927
) 3. It was limited further to "Only scroll PMs on new message" (eaf7746ec9
) 4. And later to "only scroll to bottom for discobot" (267d129f38
) 5. And the code was relegated to new-user-narrative plugin (48b7696dbc
) I don't think it's worth it to keep this scrolling code just for this very small specific case. This did potentially confict with other post scrolling code, and also using `modifyClass` is something we'd like to avoid.
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
|
|
const PLUGIN_ID = "new-user-narrative";
|
|
|
|
function initialize(api) {
|
|
const messageBus = api.container.lookup("service:message-bus");
|
|
const currentUser = api.getCurrentUser();
|
|
const appEvents = api.container.lookup("service:app-events");
|
|
|
|
api.modifyClass("component:site-header", {
|
|
pluginId: PLUGIN_ID,
|
|
didInsertElement() {
|
|
this._super(...arguments);
|
|
this.dispatch("header:search-context-trigger", "header");
|
|
},
|
|
});
|
|
|
|
api.attachWidgetAction("header", "headerSearchContextTrigger", function () {
|
|
if (this.site.mobileView) {
|
|
this.state.skipSearchContext = false;
|
|
} else {
|
|
this.state.contextEnabled = true;
|
|
this.state.searchContextType = "topic";
|
|
}
|
|
});
|
|
|
|
if (messageBus && currentUser) {
|
|
messageBus.subscribe(`/new_user_narrative/tutorial_search`, () => {
|
|
appEvents.trigger("header:search-context-trigger");
|
|
});
|
|
}
|
|
}
|
|
|
|
export default {
|
|
name: "new-user-narrative",
|
|
|
|
initialize(container) {
|
|
const siteSettings = container.lookup("service:site-settings");
|
|
if (siteSettings.discourse_narrative_bot_enabled) {
|
|
withPluginApi("0.8.7", initialize);
|
|
}
|
|
},
|
|
};
|