mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 03:07:17 -05:00
UX: hide AI gists on routes where the toggle isn't present (#35717)
AI gists were appearing in some places they shouldn't, like /my/activity/topics — this adds a check for the correct routes
This commit is contained in:
+23
-2
@@ -92,12 +92,33 @@ export default apiInitializer((api) => {
|
||||
desktop: "topic-list-topic-cell-link-bottom-line__before",
|
||||
};
|
||||
|
||||
function isGistEnabledRoute(routeName) {
|
||||
if (routeName?.startsWith("discovery.")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (routeName?.startsWith("filter")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (routeName?.startsWith("userPrivateMessages")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function renderGistInOutlet(outletName, shouldRenderFn) {
|
||||
api.renderInOutlet(
|
||||
outletName,
|
||||
class extends Component {
|
||||
static shouldRender(args, context) {
|
||||
return shouldRenderFn(context);
|
||||
static shouldRender(args, context, owner) {
|
||||
if (!shouldRenderFn(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const router = owner.lookup("service:router");
|
||||
return isGistEnabledRoute(router.currentRouteName);
|
||||
}
|
||||
|
||||
<template><AiTopicGist @topic={{@topic}} /></template>
|
||||
|
||||
Reference in New Issue
Block a user