From 0ba717e9b71038a9fca8fead6e05846d0f056dc2 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 12 Jun 2024 11:49:24 -0700 Subject: [PATCH] ensure we have permission before saving qr code --- src/components/StarterPack/QrCodeDialog.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/StarterPack/QrCodeDialog.tsx b/src/components/StarterPack/QrCodeDialog.tsx index 0f8f501be8..81b9f1f419 100644 --- a/src/components/StarterPack/QrCodeDialog.tsx +++ b/src/components/StarterPack/QrCodeDialog.tsx @@ -2,6 +2,7 @@ import React from 'react' import {View} from 'react-native' import ViewShot from 'react-native-view-shot' import * as FS from 'expo-file-system' +import {requestMediaLibraryPermissionsAsync} from 'expo-image-picker' import {AppBskyGraphDefs} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -29,6 +30,15 @@ export function QrCodeDialog({ const onSavePress = () => { ref.current?.capture?.().then(async (uri: string) => { + const res = await requestMediaLibraryPermissionsAsync() + + if (!res) { + Toast.show( + _(msg`You must grant access to your photo library to save a QR code`), + ) + return + } + const filename = `${FS.cacheDirectory}/${nanoid(12)}.png` await FS.copyAsync({from: uri, to: filename})