UX: display avatar flair in categories route topic list items (#9197)

This commit is contained in:
Vinoth Kannan 2020-03-24 01:13:25 +05:30 committed by GitHub
parent 4ecf0be93d
commit dc1836573d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 5 deletions

View File

@ -63,9 +63,19 @@ const Topic = RestModel.extend({
const latest = posters.filter(
p => p.extras && p.extras.indexOf("latest") >= 0
)[0];
user = latest && latest.user;
user = latest;
}
return user || this.creator;
return user || posters.firstObject;
},
@discourseComputed("lastPoster")
lastPosterUser(poster) {
return poster.user;
},
@discourseComputed("lastPoster")
lastPosterGroup(poster) {
return poster.primary_group;
},
@discourseComputed("posters.[]", "participants.[]", "allowed_user_count")

View File

@ -1,7 +1,14 @@
<div class='topic-poster'>
{{#user-link user=topic.lastPoster}}
{{avatar topic.lastPoster imageSize="large"}}
{{#user-link user=topic.lastPosterUser}}
{{avatar topic.lastPosterUser imageSize="large"}}
{{/user-link}}
{{#if topic.lastPosterGroup}}
{{avatar-flair
flairURL=topic.lastPosterGroup.flair_url
flairBgColor=topic.lastPosterGroup.flair_bg_color
flairColor=topic.lastPosterGroup.flair_color
groupName=topic.lastPosterGroup.name}}
{{/if}}
</div>
<div class='main-link'>
<div class='top-row'>

View File

@ -1,7 +1,7 @@
<td>
{{~#unless expandPinned}}
<div class='pull-left'>
<a href="{{topic.lastPostUrl}}" data-user-card="{{topic.last_poster_username}}">{{avatar topic.lastPoster imageSize="large"}}</a>
<a href="{{topic.lastPostUrl}}" data-user-card="{{topic.last_poster_username}}">{{avatar topic.lastPosterUser imageSize="large"}}</a>
</div>
<div class='right'>
{{else}}

View File

@ -21,7 +21,13 @@
align-items: center;
.topic-poster {
position: relative;
width: 60px;
.avatar-flair {
position: absolute;
bottom: 0;
right: 10px;
}
}
.main-link {
@extend .topic-list-main-link;

View File

@ -4,6 +4,7 @@ class CategoryAndTopicListsSerializer < ApplicationSerializer
has_one :category_list, serializer: CategoryListSerializer, embed: :objects
has_one :topic_list, serializer: TopicListSerializer, embed: :objects
has_many :users, serializer: BasicUserSerializer, embed: :objects
has_many :primary_groups, serializer: PrimaryGroupSerializer, embed: :objects
def users
users = object.topic_list.topics.map do |t|
@ -15,4 +16,14 @@ class CategoryAndTopicListsSerializer < ApplicationSerializer
users
end
def primary_groups
groups = object.topic_list.topics.map do |t|
t.posters.map { |poster| poster.try(:primary_group) }
end
groups.flatten!
groups.compact!
groups.uniq!(&:id)
groups
end
end