FIX: Never show less than 0 replies when embedding

This commit is contained in:
Robin Ward 2015-11-20 13:05:45 -05:00
parent 6ec336e56f
commit 5056de1d8a
2 changed files with 4 additions and 1 deletions

View file

@ -29,6 +29,9 @@ class EmbedController < ApplicationController
@posts_left = @topic_view.topic.posts_count - SiteSetting.embed_post_limit - 1 @posts_left = @topic_view.topic.posts_count - SiteSetting.embed_post_limit - 1
end end
@reply_count = @topic_view.topic.posts_count - 1
@reply_count = 0 if @reply_count < 0
elsif embed_url.present? elsif embed_url.present?
Jobs.enqueue(:retrieve_topic, user_id: current_user.try(:id), embed_url: embed_url) Jobs.enqueue(:retrieve_topic, user_id: current_user.try(:id), embed_url: embed_url)
render 'loading' render 'loading'

View file

@ -4,7 +4,7 @@
<% elsif @topic_view.topic.posts_count > 10 %> <% elsif @topic_view.topic.posts_count > 10 %>
<%= link_to(I18n.t('embed.continue'), @second_post_url, class: 'button', target: '_blank') %> <%= link_to(I18n.t('embed.continue'), @second_post_url, class: 'button', target: '_blank') %>
<% end %> <% end %>
<span class='replies'><%= I18n.t('embed.replies', count: @topic_view.topic.posts_count - 1) %></span> <span class='replies'><%= I18n.t('embed.replies', count: @reply_count) %></span>
</header> </header>
<%- if @topic_view.posts.present? %> <%- if @topic_view.posts.present? %>