Dont leave promise unresolved

This commit is contained in:
Paul Frazee 2024-05-06 15:44:19 -07:00
parent e1940983a3
commit fe82257801
3 changed files with 33 additions and 17 deletions

View file

@ -13,7 +13,7 @@ export async function openCamera(_opts: CameraOpts): Promise<RNImage> {
export async function openCropper(opts: CropperOptions): Promise<RNImage> {
// TODO handle more opts
return new Promise(resolve => {
return new Promise((resolve, reject) => {
unstable__openModal({
name: 'crop-image',
uri: opts.path,
@ -24,6 +24,8 @@ export async function openCropper(opts: CropperOptions): Promise<RNImage> {
onSelect: (img?: RNImage) => {
if (img) {
resolve(img)
} else {
reject(new Error('Canceled'))
}
},
})