Class: ListableTopicSerializer
Instance Method Summary
collapse
expire_cache_fragment!, fragment_cache
#include!
Instance Method Details
#bookmarked ⇒ Object
63
64
65
|
# File 'app/serializers/listable_topic_serializer.rb', line 63
def bookmarked
object.user_data && object.user_data.bookmarked
end
|
#bumped ⇒ Object
71
72
73
|
# File 'app/serializers/listable_topic_serializer.rb', line 71
def bumped
object.created_at < object.bumped_at
end
|
#excerpt ⇒ Object
112
113
114
|
# File 'app/serializers/listable_topic_serializer.rb', line 112
def excerpt
object.excerpt
end
|
#has_user_data ⇒ Object
Also known as:
include_last_read_post_number?, include_unread?, include_new_posts?, include_unread_posts?
108
109
110
|
# File 'app/serializers/listable_topic_serializer.rb', line 108
def has_user_data
!!object.user_data
end
|
#highest_post_number ⇒ Object
55
56
57
|
# File 'app/serializers/listable_topic_serializer.rb', line 55
def highest_post_number
(scope.is_whisperer? && object.highest_staff_post_number) || object.highest_post_number
end
|
#image_url ⇒ Object
33
34
35
|
# File 'app/serializers/listable_topic_serializer.rb', line 33
def image_url
object.image_url(enqueue_if_missing: true)
end
|
#include_excerpt? ⇒ Boolean
137
138
139
140
|
# File 'app/serializers/listable_topic_serializer.rb', line 137
def include_excerpt?
pinned || SiteSetting.always_include_topic_excerpts ||
theme_modifier_helper.serialize_topic_excerpts
end
|
#include_is_warning? ⇒ Boolean
87
88
89
|
# File 'app/serializers/listable_topic_serializer.rb', line 87
def include_is_warning?
is_warning
end
|
#include_last_poster? ⇒ Boolean
67
68
69
|
# File 'app/serializers/listable_topic_serializer.rb', line 67
def include_last_poster?
object.include_last_poster
end
|
#include_notification_level? ⇒ Boolean
99
100
101
|
# File 'app/serializers/listable_topic_serializer.rb', line 99
def include_notification_level?
object.user_data.present?
end
|
#include_thumbnails? ⇒ Boolean
42
43
44
45
|
# File 'app/serializers/listable_topic_serializer.rb', line 42
def include_thumbnails?
theme_modifier_helper.topic_thumbnail_sizes.present? ||
DiscoursePluginRegistry.topic_thumbnail_sizes.present?
end
|
#include_unicode_title? ⇒ Boolean
47
48
49
|
# File 'app/serializers/listable_topic_serializer.rb', line 47
def include_unicode_title?
object.title.match?(/:[\w\-+]+:/)
end
|
#include_unread_by_group_member? ⇒ Boolean
158
159
160
|
# File 'app/serializers/listable_topic_serializer.rb', line 158
def include_unread_by_group_member?
!!object.topic_list&.publish_read_state
end
|
#last_read_post_number ⇒ Object
103
104
105
106
|
# File 'app/serializers/listable_topic_serializer.rb', line 103
def last_read_post_number
return nil unless object.user_data
object.user_data.last_read_post_number
end
|
#liked ⇒ Object
59
60
61
|
# File 'app/serializers/listable_topic_serializer.rb', line 59
def liked
object.user_data && object.user_data.liked
end
|
#new_posts ⇒ Object
TODO: For backwards compatibility with themes,
Remove once Discourse 2.8 is released
127
128
129
|
# File 'app/serializers/listable_topic_serializer.rb', line 127
def new_posts
unread_helper.unread_posts
end
|
#notification_level ⇒ Object
95
96
97
|
# File 'app/serializers/listable_topic_serializer.rb', line 95
def notification_level
object.user_data.notification_level
end
|
#pinned ⇒ Object
142
143
144
|
# File 'app/serializers/listable_topic_serializer.rb', line 142
def pinned
PinnedCheck.pinned?(object, object.user_data)
end
|
#seen ⇒ Object
75
76
77
78
79
80
81
|
# File 'app/serializers/listable_topic_serializer.rb', line 75
def seen
return true if !scope || !scope.user
return true if object.user_data && !object.user_data.last_read_post_number.nil?
return true if object.dismissed
return true if object.created_at < scope.user.user_option.treat_as_new_topic_start_date
false
end
|
#thumbnails ⇒ Object
37
38
39
40
|
# File 'app/serializers/listable_topic_serializer.rb', line 37
def thumbnails
= theme_modifier_helper.topic_thumbnail_sizes
object.thumbnail_info(enqueue_if_missing: true, extra_sizes: )
end
|
#unicode_title ⇒ Object
51
52
53
|
# File 'app/serializers/listable_topic_serializer.rb', line 51
def unicode_title
Emoji.gsub_emoji_to_unicode(object.title)
end
|
#unpinned ⇒ Object
146
147
148
|
# File 'app/serializers/listable_topic_serializer.rb', line 146
def unpinned
PinnedCheck.unpinned?(object, object.user_data)
end
|
#unread ⇒ Object
TODO: For backwards compatibility with themes,
Remove once Discourse 2.8 is released
120
121
122
|
# File 'app/serializers/listable_topic_serializer.rb', line 120
def unread
0
end
|
#unread_by_group_member ⇒ Object
150
151
152
153
154
155
156
|
# File 'app/serializers/listable_topic_serializer.rb', line 150
def unread_by_group_member
return false unless object.respond_to?(:last_read_post_number)
object.last_read_post_number < object.highest_post_number
end
|
#unread_posts ⇒ Object
132
133
134
|
# File 'app/serializers/listable_topic_serializer.rb', line 132
def unread_posts
unread_helper.unread_posts
end
|
#unseen ⇒ Object
91
92
93
|
# File 'app/serializers/listable_topic_serializer.rb', line 91
def unseen
!seen
end
|