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> <tbody>
<tr data-topic-id={{topic.id}} class="{{if topic.archived 'archived'}}"> <tr data-topic-id={{topic.id}} class="{{if topic.archived 'archived'}}">
<td class="topic-poster"> <td class="topic-poster">
{{#with topic.creator as |op|}} {{#with topic.lastPoster as |lastPoster|}}
{{#user-link user=op}} {{#user-link user=lastPoster}}
{{avatar op imageSize="large"}} {{avatar lastPoster imageSize="large"}}
{{/user-link}} {{/user-link}}
{{/with}} {{/with}}
</td> </td>

View file

@ -1,4 +1,16 @@
class CategoryAndTopicListsSerializer < ApplicationSerializer class CategoryAndTopicListsSerializer < ApplicationSerializer
has_one :category_list, serializer: CategoryListSerializer, embed: :objects has_one :category_list, serializer: CategoryListSerializer, embed: :objects
has_one :topic_list, serializer: TopicListSerializer, 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 end