mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 17:12:45 +08:00
UX: reduce bottom topic map threshold, with protections (#29665)
This commit is contained in:
parent
3df3ad6ed6
commit
9a22d7df7b
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user