Removes dropping note's first visible comment in case of deleted note's author. After adding displaying "deleted" as note's description, first visible comment is now displayed as note's comment. Moves logic of calculating which note comments will be displayed and if note contains anonymous author / comments to the controller.
@note = Note.visible.find(params[:id])
@note_comments = @note.comments
end
@note = Note.visible.find(params[:id])
@note_comments = @note.comments
end
+
+ @note_includes_anonymous = @note.author.nil? || @note_comments.find { |comment| comment.author.nil? }
+
+ @note_comments = @note_comments.drop(1) unless !@note.author.nil? && @note.author.status == "deleted"
rescue ActiveRecord::RecordNotFound
render :template => "browse/not_found", :status => :not_found
end
rescue ActiveRecord::RecordNotFound
render :template => "browse/not_found", :status => :not_found
end
- <% if @note_comments.find { |comment| comment.author.nil? } -%>
+ <% if @note_includes_anonymous -%>
<p class='alert alert-warning'><%= t ".anonymous_warning" %></p>
<% end -%>
<p class='alert alert-warning'><%= t ".anonymous_warning" %></p>
<% end -%>
- <% if @note_comments.length > 1 %>
+ <% if @note_comments.length > 0 %>
<div class='note-comments'>
<ul class="list-unstyled">
<div class='note-comments'>
<ul class="list-unstyled">
- <% @note_comments.drop(1).each do |comment| %>
+ <% @note_comments.each do |comment| %>
<li id="c<%= comment.id %>">
<small class='text-body-secondary'><%= note_event(comment.event, comment.created_at, comment.author) %></small>
<div class="mx-2">
<li id="c<%= comment.id %>">
<small class='text-body-secondary'><%= note_event(comment.event, comment.created_at, comment.author) %></small>
<div class="mx-2">