From e8f0b7f49d7dfeac1a402bafd5ed0ca366eb152f Mon Sep 17 00:00:00 2001 From: Ken-ichi Ueda Date: Mon, 8 Jul 2024 15:39:33 -0700 Subject: [PATCH] Ignore iOS permission error when trying to write to gallery In theory we are checking for this permission before attempting to save, but in practice it does happen, albeit rarely. --- .../Camera/hooks/usePrepareStoreAndNavigate.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Camera/hooks/usePrepareStoreAndNavigate.js b/src/components/Camera/hooks/usePrepareStoreAndNavigate.js index 7aa442b56..08fa77c0b 100644 --- a/src/components/Camera/hooks/usePrepareStoreAndNavigate.js +++ b/src/components/Camera/hooks/usePrepareStoreAndNavigate.js @@ -44,11 +44,17 @@ export async function savePhotosToCameraGallery( // logger.info( "saved to camera roll: ", savedPhotoUri ); // Save these camera roll URIs, so later on observation editor can update // the EXIF metadata of these photos, once we retrieve a location. - // addCameraRollUri( savedPhotoUri ); onEachSuccess( savedPhotoUri ); } catch ( cameraRollSaveError ) { - logger.error( cameraRollSaveError ); - console.log( "couldn't save photo to iNaturalist Next album" ); + // This means an iOS user denied access + // (https://developer.apple.com/documentation/photokit/phphotoserror/code/accessuserdenied). + // In theory we should not even have called this function when that + // happens, but we're still seeing this in the logs. They should be + // prompted to grant permission the next time they try so this is + // probably safe to ignore. + if ( !cameraRollSaveError.message.match( /error 3311/ ) ) { + logger.error( cameraRollSaveError ); + } } }, // We need the initial value even if we're not using it, otherwise reduce