Improves behavior if note lacks opening comment

Adds checking if note lacks opening comment and if positive, returns nil for both note's author and description.
This commit is contained in:
Nenad Vujicic 2025-02-19 15:59:09 +01:00
parent 51a2d85053
commit 33dd13457c

View file

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