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 () => {
await ImagePicker.getMediaLibraryPermissionsAsync()
await ImagePicker.requestMediaLibraryPermissionsAsync()
const { uri } = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,

View File

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