Class: UserTopicBookmarkSerializer

Inherits:
UserPostTopicBookmarkBaseSerializer show all
Defined in:
app/serializers/user_topic_bookmark_serializer.rb

Instance Method Summary collapse

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

#include!

Instance Method Details

#bookmarkable_urlObject

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_userObject



33
34
35
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 33

def bookmarkable_user
  @bookmarkable_user ||= first_post.user
end

#cookedObject



29
30
31
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 29

def cooked
  first_post.cooked
end

#deletedObject



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_postObject



13
14
15
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 13

def first_post
  @first_post ||= topic.first_post
end

#hiddenObject



21
22
23
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 21

def hidden
  first_post.hidden
end

#last_read_post_numberObject



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_numberObject

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

#rawObject



25
26
27
# File 'app/serializers/user_topic_bookmark_serializer.rb', line 25

def raw
  first_post.raw
end