From dc1836573d96768b4cc685c52c2c15aeac9f069e Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Tue, 24 Mar 2020 01:13:25 +0530 Subject: [PATCH] UX: display avatar flair in categories route topic list items (#9197) --- app/assets/javascripts/discourse/models/topic.js | 14 ++++++++++++-- .../components/latest-topic-list-item.hbs | 11 +++++++++-- .../templates/mobile/list/topic-list-item.hbr | 2 +- .../stylesheets/desktop/latest-topic-list.scss | 6 ++++++ .../category_and_topic_lists_serializer.rb | 11 +++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index a3c9ee26c66..ea118dbc7af 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -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") diff --git a/app/assets/javascripts/discourse/templates/components/latest-topic-list-item.hbs b/app/assets/javascripts/discourse/templates/components/latest-topic-list-item.hbs index a1f459f725f..c071eaaef14 100644 --- a/app/assets/javascripts/discourse/templates/components/latest-topic-list-item.hbs +++ b/app/assets/javascripts/discourse/templates/components/latest-topic-list-item.hbs @@ -1,7 +1,14 @@
- {{#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}}