FIX: missing avatars from categories page when ajax loaded

UX: display last poster on categories page instead of OP
This commit is contained in:
Sam 2016-08-31 14:02:30 +10:00
parent 50379183e1
commit 55fad7b339
2 changed files with 15 additions and 3 deletions

View file

@ -2,9 +2,9 @@
<tbody>
<tr data-topic-id={{topic.id}} class="{{if topic.archived 'archived'}}">
<td class="topic-poster">
{{#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}}
</td>

View file

@ -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