Skip to content

Commit

Permalink
fix(expo): do not show reconnecting status while showing gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshvai committed Nov 6, 2023
1 parent d446e67 commit 63f5a8a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions package/expo-package/src/handlers/getPhotos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ export const getPhotos = async ({
first,
}: MediaLibrary.AssetsOptions): Promise<ReturnType> => {
try {
const { status } = await MediaLibrary.requestPermissionsAsync();
// NOTE:
// should always check first before requesting permission
// because always requesting permission will cause
// the app to go to background even if it was granted
const { status } = await MediaLibrary.getPermissionsAsync();
if (status !== 'granted') {
throw new Error('getPhotos Error');
const { status: newStatus } = await MediaLibrary.requestPermissionsAsync();
if (newStatus !== 'granted') {
throw new Error('getPhotos Error');
}
}
const results = await MediaLibrary.getAssetsAsync({
after,
Expand Down

0 comments on commit 63f5a8a

Please sign in to comment.