diff options
author | Eric Bailey <git@esb.lol> | 2023-08-29 17:09:38 -0500 |
---|---|---|
committer | Eric Bailey <git@esb.lol> | 2023-08-29 17:09:38 -0500 |
commit | 5710140a739ad73ed7650cdc1e1a848a4ee273a4 (patch) | |
tree | 6ca11d0ebb98753a5152da9d0e5298bd24c117f8 | |
parent | 6bee7d518b850fe2cbd53727c20e261d37ee0de0 (diff) | |
download | voidsky-5710140a739ad73ed7650cdc1e1a848a4ee273a4.tar.zst |
handle stuck state with granular android permissions
-rw-r--r-- | src/lib/hooks/usePermissions.ts | 11 |
1 files changed, 8 insertions, 3 deletions
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 |