-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Allow multiple avatar image types #12549
Conversation
Will add screenshots once https://github.com/Expensify/Web-Expensify/pull/35489 is merged |
…icAvatarImageTypes
isAvatarCropModalOpen: true, | ||
imageUri: image.uri, | ||
imageName: image.name, | ||
imageType: image.type, |
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.
FYI this (image type) is the main "new thing" that we're passing down to cropOrRotateImage
@@ -89,7 +89,7 @@ function cropCanvas(canvas, options) { | |||
function convertCanvasToFile(canvas, options = {}) { | |||
return new Promise((resolve) => { | |||
canvas.toBlob((blob) => { | |||
const file = new File([blob], `${options.name || 'fileName'}.jpg`, {type: 'image/jpeg'}); |
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.
Idk why we were appending .jpg
to every file name before 😅
@Santhosh-Sellavel @jasperhuangg One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Ready for review! Have fun testing uploading images :D |
@Beamanator jpg is shown jpeg refer to the video below! Initially, I checked Look at the timestamp 0:22 to 0:40 in the video below, that's where I'm checking .jpg extension. Screen.Recording.2022-11-14.at.11.03.27.PM.mov |
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.
@Santhosh-Sellavel interesting catch, I'll check that out now! |
@Santhosh-Sellavel apparently JPG and JPEG are the same actually 😅 I found lots of articles explaining, here's just one: https://www.howtogeek.com/796389/jpg-vs.-jpeg-are-they-the-same-thing/ So I don't think this is a blocker 👍 |
Let's update that in pr description jpg/jpeg will shown as jpeg in url |
Ok I'll update the OP @Santhosh-Sellavel but can you please finish your review & add the checklist?? 🙏 |
Will test today, but this PR is time-consuming 😅 |
Screen.Recording.2022-11-16.at.10.36.42.PM.mov |
Offline case does not work as expected Offline_Desktop_Web.mov |
Error is thrown while uploading BMP in iOSSimulator.Screen.Recording.-.iPhone.14.-.2022-11-16.at.23.35.16.mp4GIF extension not maintained while testing in iOS refer hereMObile_Test.movConsole error is thrown while uploading gif in Android, unable to upload here.cc: @Beamanator |
Wow thanks so much for the thorough tests @Santhosh-Sellavel - I'd definitely recommend requested increased compensation for this review :D Sadly I'm going OOO till Monday so I won't be able to fix the items you mentioned till early next week |
@Beamanator 😞 Sorry, I was waiting for the discussion outcome! Will add it soon! |
Reviewer Checklist
Screenshots/VideosWebWeb.movMobile Web - ChromeAndroid.mWeb.movMobile Web - SafariiOS_All_Files_as_JPEG.movDesktopDesktop.moviOSiOS.movAndroidAndroid.mov |
No worries @Santhosh-Sellavel thanks for sticking with me 😅 |
AH Finally completed, After double-checking multiple times, crazy PR! Tested Formats PNG, GIF, JPEG, and BMP. Web, Desktop - all works fine maintained file typed even after uploading. Uploaded Images Loading fine on all platforms. Android & iOS - Only tested PNG and JPEG. All is good here too. Mobile Web things went crazy here, after verifying multiple times Android mWebOld Story, Android Chrome uploading works after updating the chrome from the play store. PNG, GIF, JPEG - Formats works as expected file types are maintained after upload. Android_Mweb_bmp.moviOS mWebAble to upload all formats, but all are converted as JPEG and uploaded. Is converting to jPEG an issue? @Beamanator iOS_All_Files_as_JPEG.mov |
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.
Checklist: #12549 (comment)
Need clarification on this #12549 (comment), otherwise looks good!
Thanks again for the comprehensive notes & review @Santhosh-Sellavel - the one thing I don't like about turning all image types into |
Hmm so I just tested iPhone 13 simulator (iOS v15.5), Safari - and I successfully uploaded a Actually the funny thing is on the same iPhone ^ sim, I uploaded bmp & gifs, and the URL extensions were correct 🤷 (same as what I reported here). Maybe @jasperhuangg can help us test just on this platform to see what results he gets? Tested Android Chrome (updated my simulator's Chrome app & SDK version too): Got same result as you (everything worked, except |
So I'd say the next steps should be:
|
Please try in latest iOS Version. I tested on 16.1 |
We are in a never ending loop here. |
Lol! Ok I'll work on getting upgraded sims 👍 |
@Santhosh-Sellavel are you testing on a simulator with iOS 16.1 or a physical device? Please let me know which device as well |
@Beamanator NVM it's working as expected for me now on iOS mWEB, I'm not sure what I did wrong yesterday. I did the same thing today but verified it on the actual device's local storage of iOS mWeb. As updating in one platform should update in another platform I used desktop app storage, which worked right for all other platforms. Maybe it had some sync issues, as my network was also unstable yesterday. So All looks good! PNG_BMPBMP_PNG_iOS_mWEB.movJPEG_GIFJPEG_GIF_iOSMWeb.mov |
@Beamanator But BMP to JPEG on Android mWEB still occurring for me though, I believe we are okay with it! Screen.Recording.2022-12-01.at.9.38.32.PM.mov |
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.
Looks good to me!
Hey @Beamanator! I was able to successfully upload a I also repeated with The only issue I'm seeing is that the background of the cropping modal is black, which can conflict with transparent images that have black elements (as in the recording). This can probably be fixed in a followup issue. Untitled.mov |
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.
Looks good!
Merging via [2] from #12549 (comment) |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Niceee thanks y'all 👍 Will look at the other weird things y'all mentioned tomorrow 😅 |
@jasperhuangg - FYI i made a new issue about the black background when editing images here: #13266 Feel free to add your thoughts, I referenced your vid! |
🚀 Deployed to staging by @jasperhuangg in version: 1.2.36-0 🚀
|
🚀 Deployed to production by @francoisl in version: 1.2.36-4 🚀
|
Details
The main purpose of this PR is to allow users to upload multiple types of images as avatars (workspace & user avatars). Ideally we'd support at least
jpg
,jpeg
(which are the same asjpg
),gif
,png
, andbmp
. However, I investigated some errors found by @Santhosh-Sellavel here (my investigation here) where I found thatRNImageManipulator
currently only supportspng
andjpg
image types so on native we can currently only upload those types of avatar images on native.In order to not let this PR stay open for too long, I'm proposing we don't worry about those cases for now, and we create follow up issues to support those image types in that Library, or at least investigate what we should do for those image types (maybe we'd be ok just saving them as
jpg
s? To be discussed later).Fixed Issues
$ #11063
Tests
jpg
,jpeg
,gif
, andbmp
files from this site: https://filesamples.com/formats/bmp (or use your own if you have any). Also get apng
file with some transparent part (use this image if you need: https://user-images.githubusercontent.com/3885503/196921487-45bf3d63-7e42-4f4c-83d1-e8b40e519bf6.png)png
image, the image URL should end with.png
)png
, make sure the image has some transparent part, and that the transparency is preserved.jpg
andjpeg
are the same so uploading ajpg
file will change to ajpeg
file extensiononyxApiUpdate
gif
andbmp
files have issues (see investigation) so please don't worry about testing those image types on those platforms, we'll handle them in a follow-up issue. For this PR, follow steps 2 & 3 for Native devices, trying to uploadjpg
,jpeg
, andpng
images onlyOffline
QA Steps
Same as above tests - Note: after uploading on mobile, you can use Chrome to check that the uploaded image URL is correct (has the correct extension at the end) like this:
keyvaluepairs
, search for keypersonalDetails
, expand your username, findavatar
jpg
andjpeg
are the same so uploading ajpg
file will change to ajpeg
file extensionPR Author Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Screenshots
Web & iOS App
Screen.Recording.2022-11-11.at.12.02.09.PM.mov
Mobile Web - Chrome & Mobile Web - Safari
Screen.Recording.2022-11-11.at.12.26.09.PM.mov
Desktop & Android
Screen.Recording.2022-11-11.at.3.11.48.PM.mov