Class: UserTopicBookmarkSerializer
- Inherits:
-
UserPostTopicBookmarkBaseSerializer
- Object
- ActiveModel::Serializer
- ApplicationSerializer
- UserBookmarkBaseSerializer
- UserPostTopicBookmarkBaseSerializer
- UserTopicBookmarkSerializer
- Defined in:
- app/serializers/user_topic_bookmark_serializer.rb
Constant Summary
Constants included from TopicTagsMixin
TopicTagsMixin::DESCRIPTION_LIMIT
Instance Method Summary collapse
-
#bookmarkable_url ⇒ Object
NOTE: In the UI there are special topic-status and topic-link components to display the topic URL, this is only used for certain routes like the .ics bookmarks.
- #bookmarkable_user ⇒ Object
- #cooked ⇒ Object
- #deleted ⇒ Object
- #first_post ⇒ Object
- #hidden ⇒ Object
- #last_read_post_number ⇒ Object
-
#linked_post_number ⇒ Object
NOTE: It does not matter what the linked post number is for topic bookmarks, on the client we always take the user to the last unread post in the topic when the bookmark URL is clicked.
- #raw ⇒ Object
Methods inherited from UserPostTopicBookmarkBaseSerializer
#archetype, #archived, #bumped_at, #category_id, #closed, #fancy_title, #highest_post_number, #slug, #title, #topic_id
Methods included from PostItemExcerpt
#excerpt, #include_truncated?, included, #truncated
Methods included from TopicTagsMixin
#include_tags?, included, #tags, #tags_descriptions
Methods inherited from UserBookmarkBaseSerializer
#excerpt, #fancy_title, #include_reminder_at_ics_end?, #include_reminder_at_ics_start?, #reminder_at_ics_end, #reminder_at_ics_start, #title, #user
Methods inherited from ApplicationSerializer
expire_cache_fragment!, fragment_cache
Methods inherited from ActiveModel::Serializer
Instance Method Details
#bookmarkable_url ⇒ Object
NOTE: In the UI there are special topic-status and topic-link components to display the topic URL, this is only used for certain routes like the .ics bookmarks.
39 40 41 42 43 44 45 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 39 def bookmarkable_url if @options[:link_to_first_unread_post] Topic.url(topic_id, slug, (last_read_post_number || 0) + 1) else topic.url end end |
#bookmarkable_user ⇒ Object
33 34 35 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 33 def bookmarkable_user @bookmarkable_user ||= first_post.user end |
#cooked ⇒ Object
29 30 31 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 29 def cooked first_post.cooked end |
#deleted ⇒ Object
17 18 19 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 17 def deleted topic.deleted_at.present? || first_post.deleted_at.present? end |
#first_post ⇒ Object
13 14 15 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 13 def first_post @first_post ||= topic.first_post end |
#hidden ⇒ Object
21 22 23 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 21 def hidden first_post.hidden end |
#last_read_post_number ⇒ Object
47 48 49 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 47 def last_read_post_number topic_user&.last_read_post_number end |
#linked_post_number ⇒ Object
NOTE: It does not matter what the linked post number is for topic bookmarks, on the client we always take the user to the last unread post in the topic when the bookmark URL is clicked
9 10 11 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 9 def linked_post_number 1 end |
#raw ⇒ Object
25 26 27 |
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 25 def raw first_post.raw end |