From 55fad7b3391f4096ab89ffd8e2037157b2316580 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 31 Aug 2016 14:02:30 +1000 Subject: [PATCH] FIX: missing avatars from categories page when ajax loaded UX: display last poster on categories page instead of OP --- .../templates/components/latest-topic-list-item.hbs | 6 +++--- .../category_and_topic_lists_serializer.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) 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 8a64a53e8..a4d228365 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 @@ -2,9 +2,9 @@ - {{#with topic.creator as |op|}} - {{#user-link user=op}} - {{avatar op imageSize="large"}} + {{#with topic.lastPoster as |lastPoster|}} + {{#user-link user=lastPoster}} + {{avatar lastPoster imageSize="large"}} {{/user-link}} {{/with}} diff --git a/app/serializers/category_and_topic_lists_serializer.rb b/app/serializers/category_and_topic_lists_serializer.rb index 1e81bad84..239bc0798 100644 --- a/app/serializers/category_and_topic_lists_serializer.rb +++ b/app/serializers/category_and_topic_lists_serializer.rb @@ -1,4 +1,16 @@ 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 + + def users + users = object.topic_list.topics.map do |t| + t.posters.map{|poster| poster.try(:user)} + end + users.flatten! + users.compact! + users.uniq!(&:id) + users + end + end