Class: Thredded::TopicView
- Inherits:
-
BaseTopicView
- Object
- BaseTopicView
- Thredded::TopicView
- Defined in:
- app/view_models/thredded/topic_view.rb
Instance Method Summary collapse
- #last_page ⇒ Object
- #mark_as_read_path ⇒ Object
- #mark_as_unread_path ⇒ Object
- #path ⇒ Object
- #reply_path ⇒ Object
Instance Method Details
#last_page ⇒ Object
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_path ⇒ Object
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_path ⇒ Object
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 |
#path ⇒ Object
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_path ⇒ Object
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 |