mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 08:18:18 +08:00
ad082cea70
- Support for a popup that shows similar topics - Cleaned up a lot of Javascript - Cleaned up use of Promises
38 lines
765 B
Ruby
38 lines
765 B
Ruby
require_dependency 'pinned_check'
|
|
|
|
class TopicListItemSerializer < ListableTopicSerializer
|
|
|
|
attributes :views,
|
|
:like_count,
|
|
:visible,
|
|
:pinned,
|
|
:closed,
|
|
:archived,
|
|
:last_post_age,
|
|
:starred,
|
|
:has_best_of,
|
|
:archetype
|
|
|
|
has_one :category
|
|
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
|
|
|
def last_post_age
|
|
return nil if object.last_posted_at.blank?
|
|
AgeWords.age_words(Time.now - object.last_posted_at)
|
|
end
|
|
|
|
def starred
|
|
object.user_data.starred?
|
|
end
|
|
alias :include_starred? :seen
|
|
|
|
def posters
|
|
object.posters || []
|
|
end
|
|
|
|
def pinned
|
|
PinnedCheck.new(object, object.user_data).pinned?
|
|
end
|
|
|
|
end
|