Skip to content

Commit

Permalink
combine nested if
Browse files Browse the repository at this point in the history
  • Loading branch information
meghna0593 committed Jan 8, 2025
1 parent 6820322 commit 04bc0cd
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions app/src/UI/Overlay/Records/Activity/PhotoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,26 @@ const PhotoContainer: React.FC<IPhotoContainerProps> = (props) => {
try {
const permissions = await Camera.checkPermissions();

if (photoOption === CameraSource.Camera) {
if (permissions.camera === 'denied') {
dispatch(
Alerts.create({
content:
'Camera access is denied. Please enable camera permissions in your device settings to take photos.',
severity: AlertSeverity.Warning,
subject: AlertSubjects.Photo,
autoClose: 5
})
);
}
} else if (photoOption === CameraSource.Photos) {
if (permissions.photos === 'denied') {
dispatch(
Alerts.create({
content:
'Photo library access is denied. Please enable photo library permissions in your device settings to choose photos.',
severity: AlertSeverity.Warning,
subject: AlertSubjects.Photo,
autoClose: 5
})
);
}
if (photoOption === CameraSource.Camera && permissions.camera === 'denied') {
dispatch(
Alerts.create({
content:
'Camera access is denied. Please enable camera permissions in your device settings to take photos.',
severity: AlertSeverity.Warning,
subject: AlertSubjects.Photo,
autoClose: 5
})
);
} else if (photoOption === CameraSource.Photos && permissions.photos === 'denied') {
dispatch(
Alerts.create({
content:
'Photo library access is denied. Please enable photo library permissions in your device settings to choose photos.',
severity: AlertSeverity.Warning,
subject: AlertSubjects.Photo,
autoClose: 5
})
);
}
} catch (error) {
console.error('Error checking permissions:', error);
Expand Down

0 comments on commit 04bc0cd

Please sign in to comment.