Skip to content

Commit

Permalink
Catch error onClick
Browse files Browse the repository at this point in the history
  • Loading branch information
RodriSanchez1 committed Nov 14, 2023
1 parent 6e52bb8 commit 87995ca
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/components/UI/InputImage/InputImage.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,37 @@ class InputImage extends Component {
}

onClick = async () => {
const imageURL = await window.cordova.plugins.safMediastore.selectFile();
const imageName = await window.cordova.plugins.safMediastore.getFileName(
imageURL
);
const file = await new Promise((resolve, reject) => {
window.resolveLocalFileSystemURL(
imageURL,
fileEntry => {
fileEntry.file(
file => {
resolve(file);
},
err => {
console.error(err);
resolve(null);
}
);
},
err => {
console.error(err);
resolve(null);
}
try {
const imageURL = await window.cordova.plugins.safMediastore.selectFile();
const imageName = await window.cordova.plugins.safMediastore.getFileName(
imageURL
);
});
const file = await new Promise((resolve, reject) => {
window.resolveLocalFileSystemURL(
imageURL,
fileEntry => {
fileEntry.file(
file => {
resolve(file);
},
err => {
console.error(err);
resolve(null);
}
);
},
err => {
console.error(err);
resolve(null);
}
);
});

if (file) {
await this.resizeImage(file, imageName);
if (file) {
await this.resizeImage(file, imageName);
}
} catch (err) {
console.error(err);
}
};

Expand Down

0 comments on commit 87995ca

Please sign in to comment.