ensure we have permission before saving qr code
This commit is contained in:
@@ -2,6 +2,7 @@ import React from 'react'
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import ViewShot from 'react-native-view-shot'
|
import ViewShot from 'react-native-view-shot'
|
||||||
import * as FS from 'expo-file-system'
|
import * as FS from 'expo-file-system'
|
||||||
|
import {requestMediaLibraryPermissionsAsync} from 'expo-image-picker'
|
||||||
import {AppBskyGraphDefs} from '@atproto/api'
|
import {AppBskyGraphDefs} from '@atproto/api'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
@@ -29,6 +30,15 @@ export function QrCodeDialog({
|
|||||||
|
|
||||||
const onSavePress = () => {
|
const onSavePress = () => {
|
||||||
ref.current?.capture?.().then(async (uri: string) => {
|
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`
|
const filename = `${FS.cacheDirectory}/${nanoid(12)}.png`
|
||||||
await FS.copyAsync({from: uri, to: filename})
|
await FS.copyAsync({from: uri, to: filename})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user