Class: Thredded::TopicView

Inherits:
BaseTopicView
  • Object
show all
Defined in:
app/view_models/thredded/topic_view.rb

Instance Method Summary collapse

Instance Method Details

#last_pageObject



28
29
30
# File 'app/view_models/thredded/topic_view.rb', line 28

def last_page
  (@topic.posts_count / Thredded.posts_per_page.to_f).ceil # TODO: doesn't account for visibility
end

#mark_as_read_pathObject



24
25
26
# File 'app/view_models/thredded/topic_view.rb', line 24

def mark_as_read_path
  Thredded::UrlsHelper.mark_as_read_post_path(id: last_post.id, format: :json)
end

#mark_as_unread_pathObject



20
21
22
# File 'app/view_models/thredded/topic_view.rb', line 20

def mark_as_unread_path
  Thredded::UrlsHelper.mark_as_unread_post_path(id: last_post.id, format: :json)
end

#pathObject



6
7
8
9
10
11
12
13
14
# File 'app/view_models/thredded/topic_view.rb', line 6

def path
  anchor = if @read_state.first_unread_post_page
             "unread"
           elsif @topic.last_post
             "post_#{@topic.last_post.id}"
           end
  page = @read_state.first_unread_post_page || @read_state.last_read_post_page
  Thredded::UrlsHelper.topic_path(@topic, page: page, anchor: anchor)
end

#reply_pathObject



16
17
18
# File 'app/view_models/thredded/topic_view.rb', line 16

def reply_path
  Thredded::UrlsHelper.topic_path(@topic, page: last_page, anchor: "new_post")
end