From 5710140a739ad73ed7650cdc1e1a848a4ee273a4 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 29 Aug 2023 17:09:38 -0500 Subject: handle stuck state with granular android permissions --- src/lib/hooks/usePermissions.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/lib/hooks') diff --git a/src/lib/hooks/usePermissions.ts b/src/lib/hooks/usePermissions.ts index 9cb4a80dd..138f3eaca 100644 --- a/src/lib/hooks/usePermissions.ts +++ b/src/lib/hooks/usePermissions.ts @@ -29,9 +29,14 @@ export function usePhotoLibraryPermission() { if (res?.granted) { return true - } else if (!res || res?.status === 'undetermined' || res?.canAskAgain) { - const updatedRes = await requestPermission() - return updatedRes?.granted + } else if (!res || res.status === 'undetermined' || res?.canAskAgain) { + const {canAskAgain, granted, status} = await requestPermission() + + if (!canAskAgain && status === 'undetermined') { + openPermissionAlert('photo library') + } + + return granted } else { openPermissionAlert('photo library') return false -- cgit 1.4.1