diff --git a/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs b/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs index e9c924bbed0..37ceb898887 100644 --- a/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs +++ b/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs @@ -28,7 +28,7 @@ const MIN_LIKES_COUNT = 5; const MIN_PARTICIPANTS_COUNT = 5; const MIN_USERS_COUNT_FOR_AVATARS = 2; -export const MIN_POSTS_COUNT = 5; +export const MIN_POSTS_COUNT = 3; export default class TopicMapSummary extends Component { @service site; diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js index a0c56b9293e..4a3aa79198a 100644 --- a/app/assets/javascripts/discourse/app/controllers/topic.js +++ b/app/assets/javascripts/discourse/app/controllers/topic.js @@ -34,6 +34,7 @@ import Composer from "discourse/models/composer"; import Post from "discourse/models/post"; import Topic from "discourse/models/topic"; import TopicTimer from "discourse/models/topic-timer"; +import { isTesting } from "discourse-common/config/environment"; import discourseLater from "discourse-common/lib/later"; import { deepMerge } from "discourse-common/lib/object"; import discourseComputed, { bind } from "discourse-common/utils/decorators"; @@ -41,6 +42,7 @@ import I18n from "discourse-i18n"; let customPostMessageCallbacks = {}; const RETRIES_ON_RATE_LIMIT = 4; +const MIN_BOTTOM_MAP_WORD_COUNT = 200; export function resetCustomPostMessageCallbacks() { customPostMessageCallbacks = {}; @@ -233,12 +235,25 @@ export default class TopicController extends Controller.extend( return Category.findById(categoryId)?.minimumRequiredTags || 0; } - @discourseComputed("model.posts_count", "model.postStream.loadingFilter") - showBottomTopicMap(postsCount, loading) { + @discourseComputed( + "model.postStream.posts", + "model.word_count", + "model.postStream.loadingFilter" + ) + showBottomTopicMap(posts, wordCount, loading) { + // filter out small posts, because they're short + const postsCount = + posts?.filter((post) => post.post_type !== 3).length || 0; + + const minWordCount = isTesting + ? true + : wordCount > MIN_BOTTOM_MAP_WORD_COUNT; + return ( this.siteSettings.show_bottom_topic_map && !loading && - postsCount > MIN_POSTS_COUNT + postsCount > MIN_POSTS_COUNT && + minWordCount ); } diff --git a/spec/system/topic_map_spec.rb b/spec/system/topic_map_spec.rb index c836d4e8cc8..cbc21665d2c 100644 --- a/spec/system/topic_map_spec.rb +++ b/spec/system/topic_map_spec.rb @@ -21,7 +21,6 @@ describe "Topic Map", type: :system do topic_page.visit_topic(topic) expect(topic_page).to have_topic_map - 2.times { Fabricate(:post, topic: topic, created_at: 1.day.ago, like_count: 1) } page.refresh expect(topic_page).to have_topic_map expect(topic_map).to have_no_users @@ -32,6 +31,7 @@ describe "Topic Map", type: :system do # bottom map, avatars details with post counts expect(topic_map).to have_no_bottom_map + 2.times { Fabricate(:post, topic: topic, created_at: 1.day.ago, like_count: 1) } Fabricate(:post, topic: topic, created_at: 2.day.ago) Fabricate(:post, topic: topic, created_at: 1.day.ago, like_count: 3) page.refresh