-
Notifications
You must be signed in to change notification settings - Fork 312
fix: Improve GIF handling and display consistency in chat messages #984
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
Open
KrishnaShuk
wants to merge
6
commits into
RocketChat:develop
Choose a base branch
from
KrishnaShuk:fix/improve-gif-url-handling
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−16
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
29751df
fix: Improve GIF URL handling and add debugging logs
KrishnaShuk f537b90
refactor: Move styles to separate file and improve accessibility in I…
KrishnaShuk 8a7781c
chore: Remove console logs and fix formatting
KrishnaShuk 70ac232
Merge branch 'develop' into fix/improve-gif-url-handling
Spiral-Memory 92a9496
refactor: simplify URL handling for file uploads in Attachment component
KrishnaShuk eecd589
Merge branch 'fix/improve-gif-url-handling' of https://github.com/Kri…
KrishnaShuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/react/src/views/AttachmentHandler/ImageAttachment.styles.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { css } from '@emotion/react'; | ||
|
||
export const imageWrapper = ({ isGif, theme }) => css` | ||
width: ${isGif ? '200px' : '300px'}; | ||
height: ${isGif ? '200px' : 'auto'}; | ||
overflow: hidden; | ||
border-radius: inherit; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: ${theme.colors.surface}; | ||
`; | ||
|
||
export const imageStyles = ({ isGif }) => ({ | ||
width: isGif ? '200px' : '100%', | ||
height: isGif ? '200px' : 'auto', | ||
maxHeight: isGif ? '200px' : '200px', | ||
objectFit: isGif ? 'cover' : 'scale-down', | ||
borderRadius: 'inherit', | ||
imageRendering: isGif ? 'auto' : 'inherit', | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the reasoning behind checking whether http is present, then extracting the full URL and everything else
Can't we do it without these manual interventions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here was to handle two possible cases: absolute URLs (like https://example.com/file-upload/123) that are good to go as-is, and relative ones (like /file-upload/123) that need the host tacked on to work. I check for http to figure out which case I’m dealing with, so I don’t accidentally double up the host on an absolute URL or leave a relative one incomplete. The splitting part just grabs the file ID after /file-upload/ to rebuild the URL properly.
we could just assume everything’s relative and put host on front, though that’d break if an absolute URL slips in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why there will be a difference ? I mean once the image is uploaded, it will have any one of these URLs right ? Have you observed anything that in what cases, there could be a chance of absolute / relative URLs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No i haven't checked the cases. I have just guessed it. And you are right that once the image is uploaded it will have any one of these URLs. Should i make a commit in which url is put out directly without any condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, check which kind of url is present after the upload and based on it, just use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The url is of relative type. Sould i totally remove the conditions logic or use this instead -> const fullUrl =
${host}/file-upload/${url.split('/file-upload/')[1]}
;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, pls go ahead with the new change and once you're done, request a re-review
Thanks a lot for the contribution 😌😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @Spiral-Memory! These conversations surely help me in leveling up.