Fix bug causing Publish to never ask for media permissions

This commit is contained in:
Nat 2021-08-01 16:54:47 -03:00
parent 9062206c34
commit 3eb7b250d8
3 changed files with 27 additions and 11833 deletions

11843
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -89,7 +89,7 @@ const SettingsJsx = (props) => {
}, []); }, []);
const _handleChangeProfilePhoto = async () => { const _handleChangeProfilePhoto = async () => {
await ImagePicker.getMediaLibraryPermissionsAsync() await ImagePicker.requestMediaLibraryPermissionsAsync()
const { uri } = await ImagePicker.launchImageLibraryAsync({ const { uri } = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true, allowsEditing: true,

View File

@ -35,22 +35,23 @@ const PublishJsx = ({ navigation }) => {
instance = instancePair[1]; instance = instancePair[1];
accessToken = JSON.parse(tokenPair[1]).access_token; accessToken = JSON.parse(tokenPair[1]).access_token;
return ImagePicker.getMediaLibraryPermissionsAsync(); return ImagePicker.requestMediaLibraryPermissionsAsync();
}) })
.then(({ granted }) => { .then(permissionResult => {
if (granted) { console.warn(permissionResult);
if (permissionResult.granted) {
return ImagePicker.launchImageLibraryAsync({ return ImagePicker.launchImageLibraryAsync({
allowsEditing: true, allowsEditing: true,
}); });
} else { } else {
navigation.goBack(); throw "Permission not granted";
} }
}) })
.then((imageData) => { .then((imageData) => {
if (!imageData.cancelled) { if (!imageData.cancelled) {
return imageData; return imageData;
} else { } else {
navigation.goBack(); throw "Image picker closed";
} }
}) })
.then(({ uri, type, width, height }) => { .then(({ uri, type, width, height }) => {
@ -71,6 +72,10 @@ const PublishJsx = ({ navigation }) => {
height: getAutoHeight(width, height, SCREEN_WIDTH), height: getAutoHeight(width, height, SCREEN_WIDTH),
}, },
}); });
})
.catch(e => {
console.warn(e);
navigation.goBack();
}); });
}, []); }, []);