Fixes: Save profile picture automatically after upload

Fix jank when cropping large photos
This commit is contained in:
Tom Moor
2018-11-17 18:25:10 -08:00
parent d3834d2dc5
commit d74b99635e
3 changed files with 15 additions and 3 deletions

View File

@ -38,8 +38,15 @@ class DropToImport extends React.Component<Props> {
this.file = files[0];
};
handleCrop = async () => {
handleCrop = () => {
this.isUploading = true;
// allow the UI to update before converting the canvas to a Blob
// for large images this can cause the page rendering to hang.
setImmediate(this.uploadImage);
};
uploadImage = async () => {
const canvas = this.avatarEditorRef.getImage();
const imageBlob = dataUrlToBlob(canvas.toDataURL());
try {