Skip to content

fix(Comment): guard against undefined current user in reply delete vi… - #2197

Merged
frankrousseau merged 1 commit into
cgwire:mainfrom
chauquocdung:fix/comment-reply-delete-undefined-user
Sep 7, 2026
Merged

fix(Comment): guard against undefined current user in reply delete vi…#2197
frankrousseau merged 1 commit into
cgwire:mainfrom
chauquocdung:fix/comment-reply-delete-undefined-user

Conversation

@chauquocdung

Copy link
Copy Markdown

Problem

Any comment with a reply becomes invisible to non-admin/manager users.
Comment.vue's reply-delete button check references user.id, but
user is never declared anywhere in the component (no prop, ref,
computed, or store destructure) - it resolves to undefined at runtime.
isCurrentUserAdmin || replyComment.person_id === user.id only crashes
for non-admins, since || short-circuits before user.id is evaluated
for an admin/manager. This is a related gap left by #2168, which added
null-safety to the reply author's avatar but not this separate check.

Solution

Replace user.id with store.state.user.user?.id, the pattern already
used elsewhere in this codebase (e.g. src/lib/init.js) for the current
user's id, with optional chaining for safety.

@frankrousseau
frankrousseau merged commit 4288910 into cgwire:main Sep 7, 2026
@frankrousseau

Copy link
Copy Markdown
Contributor

Thank you @chauquocdung!

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