mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Only render group card if user title is from group (#9946)
This was failing when a user with a primary_group chose to display a title coming from a badge.
This commit is contained in:
@@ -47,6 +47,7 @@ export function transformBasicPost(post) {
|
|||||||
new_user: post.trust_level === 0,
|
new_user: post.trust_level === 0,
|
||||||
name: post.name,
|
name: post.name,
|
||||||
user_title: post.user_title,
|
user_title: post.user_title,
|
||||||
|
title_is_group: post.title_is_group,
|
||||||
created_at: post.created_at,
|
created_at: post.created_at,
|
||||||
updated_at: post.updated_at,
|
updated_at: post.updated_at,
|
||||||
canDelete: post.can_delete,
|
canDelete: post.can_delete,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ createWidget("poster-name-title", {
|
|||||||
|
|
||||||
html(attrs) {
|
html(attrs) {
|
||||||
let titleContents = attrs.title;
|
let titleContents = attrs.title;
|
||||||
if (attrs.primaryGroupName) {
|
if (attrs.primaryGroupName && attrs.titleIsGroup) {
|
||||||
const href = Discourse.getURL(`/g/${attrs.primaryGroupName}`);
|
const href = Discourse.getURL(`/g/${attrs.primaryGroupName}`);
|
||||||
titleContents = h(
|
titleContents = h(
|
||||||
"a.user-group",
|
"a.user-group",
|
||||||
@@ -126,10 +126,15 @@ export default createWidget("poster-name", {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = attrs.user_title;
|
const title = attrs.user_title,
|
||||||
|
titleIsGroup = attrs.title_is_group;
|
||||||
if (title && title.length) {
|
if (title && title.length) {
|
||||||
contents.push(
|
contents.push(
|
||||||
this.attach("poster-name-title", { title, primaryGroupName })
|
this.attach("poster-name-title", {
|
||||||
|
title,
|
||||||
|
primaryGroupName,
|
||||||
|
titleIsGroup
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class PostSerializer < BasicPostSerializer
|
|||||||
:link_counts,
|
:link_counts,
|
||||||
:read,
|
:read,
|
||||||
:user_title,
|
:user_title,
|
||||||
|
:title_is_group,
|
||||||
:reply_to_user,
|
:reply_to_user,
|
||||||
:bookmarked,
|
:bookmarked,
|
||||||
:bookmark_reminder_at,
|
:bookmark_reminder_at,
|
||||||
@@ -212,6 +213,14 @@ class PostSerializer < BasicPostSerializer
|
|||||||
object&.user&.title
|
object&.user&.title
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def title_is_group
|
||||||
|
object&.user&.title == object.user&.primary_group&.title
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_title_is_group?
|
||||||
|
object&.user&.title.present?
|
||||||
|
end
|
||||||
|
|
||||||
def trust_level
|
def trust_level
|
||||||
object&.user&.trust_level
|
object&.user&.trust_level
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user