From: Nenad Vujicic Date: Tue, 4 Feb 2025 16:30:10 +0000 (+0100) Subject: Removes dropping note's first comment X-Git-Tag: live~151^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/592b28fd23534946b92ace7858287727e4afc169 Removes dropping note's first comment 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. --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 4b4f3d651..574c9b8b7 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -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 diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index 4f20cdd44..b65926b5f 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -22,7 +22,7 @@

- <% if @note_comments.find { |comment| comment.author.nil? } -%> + <% if @note_includes_anonymous -%>

<%= t ".anonymous_warning" %>

<% end -%> @@ -52,10 +52,10 @@ <% end %> - <% if @note_comments.length > 1 %> + <% if @note_comments.length > 0 %>