[HOLD for payment 2021-09-17] Workspace - Add Loading UI after user saves profile photo
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Issue was found when executing this PR #4298
Action Performed:
- Lunch the app
- Log in with expensifail account
- Go to Settings - click on any workspace
- Click on picture pen and click upload
- Click on Save button
Expected Result:
Able to save picture only on first press on the button
Actual Result:
Able to save picture only on second press or 3rd press of the button
Workaround:
Unknown
Platform:
Where is this issue occurring?
- Android
Version Number: 1.0.83-0 Logs: https://stackoverflow.com/c/expensify/questions/4856 **Notes/Photos/Videos:
https://user-images.githubusercontent.com/43996225/128581801-01dae2cd-8dff-4295-9c76-0c86e109d193.mp4
Expensify/Expensify Issue URL:
:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
- Identify the pull request that introduced this issue and revert it.
- Find someone who can quickly fix the issue.
- Fix the issue yourself.
Triggered auto assignment to @ctkochan22 (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Proposal
The user doesn't have to click twice to save the picture. Basically, there isn't any feedback to the user on changes being saved. Need to do two things:
- Show a success/error message on Save
- While the API is running disable the Save button
In WorkspaceEditorPage.js,
this.state = {
isSubmitting: true
}
submit() {
this.setState({ isSubmitting: true});
this.uploadAvatarPromise.then(() => {
const name = this.state.name.trim();
const avatarURL = this.state.avatarURL;
const policyID = this.props.policy.id;
update(policyID, {name, avatarURL});
this.setState({ isSubmitting: false}); // Manage flag state
Growl.sucess(translate('updatesuccess')); // Show feedback to the server
}).catch(err => {
this.setState({ isSubmitting: false});
Growl.error(translate('updateFailed'));
});
}.
<Button
success
isDisabled={this.state.isSubmitting} /// Disable button when submitting
style={[styles.w100]}
text={this.props.translate('workspace.editor.save')}
onPress={this.submit}
pressOnEnter
/>
Try with a smaller size image you'll see it redirects quickly.
I don't think this is a blocker. It looks like there is just no UI feedback that indicates that the request was sent and we are awaiting a response.
Can we close this or edit the title to `Add loading gif/ui once "save" button is clicked
Triggered auto assignment to @puneetlath (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.
I was able to confirm that this behavior is also happening on iOS as well.
@ctkochan22 if you think this is a good external candidate, add the external label please!
Triggered auto assignment to @jboniface (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
weird that being assigned something via auto assigner doesn't remove the overdue label. this made it seem like I had an issue overdue, when really I'd just been assigned to it a couple hours ago.
posted https://www.upwork.com/jobs/~01cdb87ac85566935f
Triggered auto assignment to @roryabraham (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Proposal
-
We can use a flag in state
loadingthat keeps track of the update promise. -
on Submit , set this flag to
true, and then when the promise resolves set is back tofalse. https://github.com/Expensify/App/blob/e4f4ed7b9f649d46c2cc0696f4bf5e3bcf0403a4/src/pages/workspace/WorkspaceEditorPage.js#L65 -
If we want to truly track the update process. We can return the API promise here https://github.com/Expensify/App/blob/e4f4ed7b9f649d46c2cc0696f4bf5e3bcf0403a4/src/libs/actions/Policy.js#L243
-
thus waiting for both
uploadAvatarPromiseand Save Api calls promises to resolve before setting theloadingtofalse. Otherwise, we can just set the flag afteruploadAvatarPromiseresolves. 5.Finally using thisflagon the ButtonisLoadingprop. https://github.com/Expensify/App/blob/e4f4ed7b9f649d46c2cc0696f4bf5e3bcf0403a4/src/pages/workspace/WorkspaceEditorPage.js#L125. -
Optionally, we can show a success message after Everything is done.
Growl.show(this.props.translate('workspaceEdit.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000);
cc: @roryabraham Proposal https://github.com/Expensify/App/issues/4487#issuecomment-894579175
Very sorry for the delay here. @mananjadhav your original proposal looks good 👍
The only thing I would add is that the save button should be disabled if there are no changes from what is already saved.
Okay @roryabraham I'll take a note of that. I'll check if the image is replaced or the title is changed and accordingly enabled/disable the save button.
@jboniface, @roryabraham it looks like no one is assigned to work on this job. Please double the price or add a comment stating why the job isn't being doubled.
@jboniface Let's hire @mananjadhav for this so he can get started implementing the solution 👍
progress is still being made on the PR
PR is under review.
@roryabraham @jboniface
I was wondering if we could bump the budget for this one considering the amount of work we achieved with the PR.
Wouldn't have asked if I was the reporter as would've received the bonus. Hope you'll consider.