forked from VinkasHQ/discourse-timeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.rb
30 lines (20 loc) · 722 Bytes
/
plugin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# name: timeline
# about: Social network news feed like UI in topic list.
# version: 0.0.1
# authors: Vinoth Kannan (vinothkannan@vinkas.com)
# url: https://github.com/VinkasHQ/discourse-timeline
register_asset "stylesheets/timeline.scss"
register_svg_icon "trash" if respond_to?(:register_svg_icon)
after_initialize do
TopicListItemSerializer.class_eval do
has_one :unread_post, serializer: PostSerializer, embed: :objects
def unread_post
return object.first_post unless last_read_post_number
return nil if last_read_post_number == object.highest_post_number
object.posts.find_by(post_number: last_read_post_number + 1)
end
def include_excerpt?
false
end
end
end