Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug when deleted user's note lacks comments #5609

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nenad-vujicic
Copy link
Contributor

Description

PR fixes bug where a note of deleted user has no comments, but the code tries to access the first comment by switching to using .all_comments (instead of .comments) and removing dropping first comment (if author is deleted) when displaying notes comments in sidebar.

Suggested here.

How has this been tested?

Automated tests, manual testing before and after migration.

@@ -52,10 +52,10 @@
<% end %>
</div>

<% if @note_comments.length > 1 %>
<% if @note_comments.length > (!@note.author.nil? && @note.author.status == "deleted" ? 0 : 1) %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to make @note_comments contain true comments in the controller instead of having this condition checked twice here.

@note_comments were used in three places of this view: description, anonymous warning and discussion.

  • Description is handled differently now.
  • Discussion is going to work with all @note_comments without deciding which to drop.
  • Anonymous warning will need to check if either note author is nil or any comment's author is nil. Maybe this check is also better done in the controller and saved to some variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the last push. Thanks!

Q: Do we need to replace current anonymous warning to something like "This note is created by anonymous user or includes comments from anonymous users so should be independently verified." or current message is good enough?

Switches from using note's .comments to .all_comments. Fixes bug with notes of deleted users without comments, which are filtered out, but the code tries to access the 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.
@nenad-vujicic nenad-vujicic force-pushed the issue_replace_opening_comment_task_6 branch from 0c08a73 to 592b28f Compare February 6, 2025 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants