Merge branch 'pull/5609'

This commit is contained in:
Anton Khorev 2025-02-06 18:15:58 +03:00
commit 1e0377e6b3
3 changed files with 9 additions and 5 deletions

View file

@ -40,6 +40,10 @@ class NotesController < ApplicationController
@note = Note.visible.find(params[:id]) @note = Note.visible.find(params[:id])
@note_comments = @note.comments @note_comments = @note.comments
end 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 rescue ActiveRecord::RecordNotFound
render :template => "browse/not_found", :status => :not_found render :template => "browse/not_found", :status => :not_found
end end

View file

@ -94,7 +94,7 @@ class Note < ApplicationRecord
# Return the note's description, derived from the first comment # Return the note's description, derived from the first comment
def description def description
if user_ip.nil? && user_id.nil? if user_ip.nil? && user_id.nil?
comments.first.body all_comments.first.body
else else
RichText.new("text", super) RichText.new("text", super)
end end
@ -103,7 +103,7 @@ class Note < ApplicationRecord
# Return the note's author object, derived from the first comment # Return the note's author object, derived from the first comment
def author def author
if user_ip.nil? && user_id.nil? if user_ip.nil? && user_id.nil?
comments.first.author all_comments.first.author
else else
super super
end end

View file

@ -22,7 +22,7 @@
</p> </p>
</div> </div>
<% if @note_comments.find { |comment| comment.author.nil? } -%> <% if @note_includes_anonymous -%>
<p class='alert alert-warning'><%= t ".anonymous_warning" %></p> <p class='alert alert-warning'><%= t ".anonymous_warning" %></p>
<% end -%> <% end -%>
@ -52,10 +52,10 @@
<% end %> <% end %>
</div> </div>
<% if @note_comments.length > 1 %> <% if @note_comments.length > 0 %>
<div class='note-comments'> <div class='note-comments'>
<ul class="list-unstyled"> <ul class="list-unstyled">
<% @note_comments.drop(1).each do |comment| %> <% @note_comments.each do |comment| %>
<li id="c<%= comment.id %>"> <li id="c<%= comment.id %>">
<small class='text-body-secondary'><%= note_event(comment.event, comment.created_at, comment.author) %></small> <small class='text-body-secondary'><%= note_event(comment.event, comment.created_at, comment.author) %></small>
<div class="mx-2"> <div class="mx-2">