]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5623'
authorTom Hughes <tom@compton.nu>
Thu, 6 Feb 2025 17:13:03 +0000 (17:13 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 6 Feb 2025 17:13:03 +0000 (17:13 +0000)
app/controllers/notes_controller.rb
app/models/note.rb
app/views/notes/show.html.erb

index 4b4f3d6515f3698370e74d2c92cc96b779b642ac..574c9b8b7d512ba745964711bd76f13fbe2f4631 100644 (file)
@@ -40,6 +40,10 @@ class NotesController < ApplicationController
       @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
index d37b863e53b5a77224375fc48990860144171cfe..807ee9ec8b99a7e021ac9ba8b46963c2f74cd2a8 100644 (file)
@@ -94,7 +94,7 @@ class Note < ApplicationRecord
   # Return the note's description, derived from the first comment
   def description
     if user_ip.nil? && user_id.nil?
-      comments.first.body
+      all_comments.first.body
     else
       RichText.new("text", super)
     end
@@ -103,7 +103,7 @@ class Note < ApplicationRecord
   # Return the note's author object, derived from the first comment
   def author
     if user_ip.nil? && user_id.nil?
-      comments.first.author
+      all_comments.first.author
     else
       super
     end
index 4f20cdd441a227329bc4fca28bcf572c3ad5d016..b65926b5f9df335fd7abbcfda573cfef93ad8c8c 100644 (file)
@@ -22,7 +22,7 @@
     </p>
   </div>
 
-  <% if @note_comments.find { |comment| comment.author.nil? } -%>
+  <% if @note_includes_anonymous -%>
     <p class='alert alert-warning'><%= t ".anonymous_warning" %></p>
   <% end -%>
 
     <% end %>
   </div>
 
-  <% if @note_comments.length > 1 %>
+  <% if @note_comments.length > 0 %>
     <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">