mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-07 08:54:19 +08:00
Allow filtering posts by user from the user card even when the user’s profile is hidden. ### Context The filter button was missing for hidden profiles because `topic_post_count` wasn’t exposed in `HiddenProfileSerializer`. ### Changes * include `topic_post_count` in `HiddenProfileSerializer` - enables filter button rendering on a user card for hidden profiles * extract duplicate logic into private method `assign_topic_post_count` * remove unused parameter `username` in `filterPostsLabel` computed property |Before|After| |---|---| |<img width="707" height="209" alt="Screenshot 2025-11-07 at 22 39 07" src="https://github.com/user-attachments/assets/4de036f2-2dbe-4a59-98db-0e8aea16a2a5" />|<img width="706" height="258" alt="Screenshot 2025-11-07 at 22 37 51" src="https://github.com/user-attachments/assets/7e82b7e9-d796-4ea5-89c0-47220e57af07" />|
29 lines
526 B
Ruby
29 lines
526 B
Ruby
# frozen_string_literal: true
|
|
|
|
class HiddenProfileSerializer < BasicUserSerializer
|
|
attr_accessor :topic_post_count
|
|
|
|
attributes(
|
|
:profile_hidden?,
|
|
:title,
|
|
:topic_post_count,
|
|
:primary_group_name,
|
|
:can_send_private_message_to_user,
|
|
)
|
|
|
|
def profile_hidden?
|
|
true
|
|
end
|
|
|
|
def can_send_private_message_to_user
|
|
scope.can_send_private_message?(object)
|
|
end
|
|
|
|
def primary_group_name
|
|
object.primary_group.try(:name)
|
|
end
|
|
|
|
def include_topic_post_count?
|
|
topic_post_count.present?
|
|
end
|
|
end
|