-
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
[HOLD for payment 2021-11-22] Profile - Uploading a non-image file will show infinite loading and blocks the user from uploading a new profile picture #5593
Comments
Triggered auto assignment to @yuwenmemon ( |
Proposed Solution: (If considered as external)There are two problem here: First is Non Image file (e.g. txt) Uploaded: I am not sure why sometime api throw error with {jsonCode: 404, ... } OR Sometime returns response with {jsonCode: 502, ... }. May be server side issue or maintenance. So I suggested solution that will handle all situation. Second is Unsupported Image Uploaded: So in both case it goes to loading state because we are just handling App/src/libs/actions/PersonalDetails.js Lines 273 to 281 in fa7cb60
So we have to update setAvatar() actions as under within src/libs/actions/PersonalDetails.js file: function setAvatar(file) {
setPersonalDetails({avatarUploading: true});
API.User_UploadAvatar({file})
.then((response) => {
// Once we get the s3url back, update the personal details for the user with the new avatar URL
if (response.jsonCode === 200) {
setPersonalDetails({avatar: response.s3url, avatarUploading: false}, true);
} else {
setPersonalDetails({avatarUploading: false});
Growl.show(translateLocal('profilePage.avatarUploadFailureMessage'), CONST.GROWL.ERROR, 3000);
}
})
.catch((error) => {
setPersonalDetails({avatarUploading: false});
if (error.jsonCode === 404) {
Growl.show(translateLocal('profilePage.invalidFileMessage'), CONST.GROWL.ERROR, 3000);
} else {
Growl.show(translateLocal('profilePage.avatarUploadFailureMessage'), CONST.GROWL.ERROR, 3000);
}
});
} Also within language file we have to add translation as under: profilePage: {
...,
invalidFileMessage: 'Invalid file. Please try a different image.',
avatarUploadFailureMessage: 'An error occurred uploading the avatar, please try again.',
}, src/languages/es.js profilePage: {
...,
invalidFileMessage: 'Archivo inválido. Pruebe con una imagen diferente.',
avatarUploadFailureMessage: 'No se pudo subir el avatar. Por favor, inténtalo de nuevo.',
}, Below is screen record, How it works after update: Web.mov |
This can be worked on by a contributor. |
Triggered auto assignment to @dylanexpensify ( |
Working on this now! |
Posted! Internal: https://www.upwork.com/ab/applicants/1445266428359061504/job-details |
Triggered auto assignment to @thienlnam ( |
@dylanexpensify, If my suggested solution #5593 (comment) work then kindly accept my proposal on upwork. So I can proceed to submit pr. |
please accept my proposal so that I can work according to your requirements |
@PrashantMangukiya Great proposal and good catch on the handling with the .catch and the .then. This solution works but as you mentioned we have some server side handling that will sometimes not throw the error. That's something I will look into internally but for your proposal, lets only keep the handling in .catch and remove the if/else in the .then |
@gaurav27ats Thanks for your interest! Please read over https://github.com/Expensify/App/blob/main/CONTRIBUTING.md#working-on-expensify-jobs for future reference as you'll need to propose a solution in the Github issue |
@thienlnam Thank you for the message. Below is the updated solution. Existing code for setAvatar() is as under: App/src/libs/actions/PersonalDetails.js Lines 273 to 281 in fa7cb60
Solution: We have to add .catch() block within setAvatar() actions, .then() block logic remain as it is. Note: Previously I suggested else condition within then() block. Now no else condition in .then() block. So server side team please make sure to throw error() with 404 in case of invalid file etc. so it can be handled via catch() block. function setAvatar(file) {
setPersonalDetails({avatarUploading: true});
API.User_UploadAvatar({file})
.then((response) => {
// Once we get the s3url back, update the personal details for the user with the new avatar URL
if (response.jsonCode === 200) {
setPersonalDetails({avatar: response.s3url, avatarUploading: false}, true);
}
})
.catch((error) => {
setPersonalDetails({avatarUploading: false});
if (error.jsonCode === 404) {
Growl.show(translateLocal('profilePage.invalidFileMessage'), CONST.GROWL.ERROR, 3000);
} else {
Growl.show(translateLocal('profilePage.avatarUploadFailureMessage'), CONST.GROWL.ERROR, 3000);
}
});
} We have to add translation within src/languages/en.js: profilePage: {
...,
invalidFileMessage: 'Invalid file. Please try a different image.',
avatarUploadFailureMessage: 'An error occurred uploading the avatar, please try again.',
}, We have to add translation within src/languages/es.js: profilePage: {
...,
invalidFileMessage: 'Archivo inválido. Pruebe con una imagen diferente.',
avatarUploadFailureMessage: 'No se pudo subir el avatar. Por favor, inténtalo de nuevo.',
}, If this solution ok then please message once we are ready to move forward. So I will proceed to submit pr. |
Please refer to this post for updated information on the |
Removed hold, $250 bonus applies |
not overdue |
@PrashantMangukiya The mentioned PR is on production and I also updated one of the codes to a 405 instead of a 404 for an invalid image. Please give it another test and let's continue implementation specific comments in the PR |
@thienlnam thanks for the message. Today I am busy, so tomorrow I will test and continue for implementation in the PR. I will message if need any other help. Thanks again. |
@thienlnam I tested it with latest version. Still it is returning 502 code within then() block if invalid image file uploaded. Here is latest screenshot from web debug. It looks like there is not any api changes at server side etc. |
Gotcha, in that case go ahead and use parasharrajat's suggestion and handle errors by throwing inside the .then() if it's not a 200 |
Thanks @thienlnam I will implement it as per parasharrajat's suggestion |
not overdue |
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.14-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2021-11-22. 🎊 |
@dylanexpensify Ping for Upwork payment. |
On it now @PrashantMangukiya! |
Payment sent (with Bonus), contract cancelled, and job posting deleted! |
Ah shoot, thanks @mallenexpensify! Completely missed this, my bad! |
Paid @Hanaffi in Upwork for reporting |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia ( |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
There should be a message about a invalid file uploaded.
Actual Result:
There's an infinite loading displayed under the avatar icon. No option to upload a new image is displayed.
Workaround:
None found. Refreshing doesn't fix the issue. Only logging out and back will remove the infinite loading.
Platform:
Where is this issue occurring?
Version Number: 1.1.3-0
Reproducible in staging?: yes
Reproducible in production?: yes
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
prfile.mp4
Expensify/Expensify Issue URL:
Issue reported by: @Hanaffi
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1632870641227600
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: