Skip to content

fix(react): resolve nested video attachment source, author info, and … - #1448

Open
swarnendusahu10-dotcom wants to merge 2 commits into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/video-attachment-nested-source-and-author
Open

swarnendusahu10-dotcom wants to merge 2 commits into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/video-attachment-nested-source-and-author

Conversation

@swarnendusahu10-dotcom

Copy link
Copy Markdown
Contributor

Summary

Fixes copy-paste reference bugs in VideoAttachment (packages/react/src/views/AttachmentHandler/VideoAttachment.js) that caused nested video attachments (inside quotes, replies, or forwarded messages) to play the parent video, display the wrong author avatar/username, and evaluate the wrong attachment type for border styling.

Problem

When mapping over nested attachments (attachment.attachments.map((nestedAttachment, index) => ...)):

  1. Wrong Video Playback: <source src={host + attachment.video_url} ... /> referenced the outer parent's attachment.video_url rather than nestedAttachment.video_url. As a result, quoted or forwarded video attachments played the parent message's video instead of their own.
  2. Incorrect Author Attribution: The avatar and username rendered authorIcon and authorName from the parent closure scope instead of nestedAttachment.author_icon and nestedAttachment.author_name.
  3. Incorrect Border Type Evaluation: The border styling evaluated ${type === 'file'} (parent type) instead of ${nestedAttachment.type === 'file'}.
  4. Missing Null Guards: If author was omitted or icon was missing in getUserAvatarUrl, it led to potential unhandled runtime exceptions or malformed URL strings (${instanceHost}undefined).

Solution

  1. Changed nested video source to host + nestedAttachment.video_url.
  2. Changed nested author avatar and username to nestedAttachment.author_icon and nestedAttachment.author_name.
  3. Updated border condition to evaluate nestedAttachment.type === 'file'.
  4. Added default author = {} and safe navigation in getUserAvatarUrl to guard against missing icons or uninitialized context.
  5. Added missing propTypes (type, author, variantStyles, msg).

Testing

  • Verified that nested/quoted video attachments play their own video URL and display their own author avatar and username.
  • Ran eslint src/views/AttachmentHandler/VideoAttachment.js: 0 errors, 0 warnings.
  • Ran yarn build: Rollup build completed successfully with 0 errors.

This branch has not been deployed

No deployments
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.

1 participant