UX: Don't highlight the latest poster in the topic list if there is only

one avatar shown.
This commit is contained in:
Robin Ward 2014-08-20 12:09:39 -04:00
parent 2b5feda625
commit 6ef85ea014
2 changed files with 7 additions and 6 deletions

View file

@ -16,7 +16,7 @@ class TopicPostersSummary
TopicPoster.new.tap do |topic_poster|
topic_poster.user = user
topic_poster.description = descriptions_for(user)
topic_poster.extras = 'latest' if is_latest_poster?(user)
topic_poster.extras = 'latest' if include_latest_class?(user)
end
end
@ -29,6 +29,10 @@ class TopicPostersSummary
end
end
def include_latest_class?(user)
topic.last_post_user_id == user.id && user_ids.uniq.size > 1
end
def descriptions_for(user)
descriptions_by_id[user.id].join ', '
end
@ -56,10 +60,6 @@ class TopicPostersSummary
topic.user_id == topic.last_post_user_id
end
def is_latest_poster?(user)
topic.last_post_user_id == user.id
end
def sorted_top_posters
shuffle_last_poster_to_back_in top_posters
end

View file

@ -27,7 +27,6 @@ describe TopicPostersSummary do
summary.first.tap do |topic_poster|
expect(topic_poster.user).to eq topic_creator
expect(topic_poster.extras).to eq 'latest'
expect(topic_poster.description).to eq(
"#{I18n.t(:original_poster)}, #{I18n.t(:most_recent_poster)}"
)
@ -65,6 +64,8 @@ describe TopicPostersSummary do
featured_user1, featured_user2, featured_user3,
last_poster
])
# If more than one user, attach the latest class
expect(summary.last.extras).to eq 'latest'
end
end
end