-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add check with navigation when PermissionAudio BottomSheet is open, a… #384
Conversation
bohdanprog
commented
May 28, 2024
- add check with navigation when PermissionAudio BottomSheet is open.
- comment line with navigation function because those screens don't exist in the main branch.
…nd comment line with navigate function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not working as expected:
https://github.com/digidem/comapeo-mobile/assets/67773827/e367065c-eb26-4708-a78d-3649a84f59a2
@@ -69,7 +69,8 @@ export const ThumbnailAndActionTab: FC<ThumbnailAndActionTab> = ({ | |||
|
|||
const handleAudioPress = useCallback(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
navigation
can be taken out of the dependency array for use callback
@ErikSin here is the reason why we made that in that way. I agreed with that solution; unfortunately, I didn't check all the cases. Here is solution where we handled all cases. We can change that if it looks good for you. Thanks |
Sorry im a little confused. Right now, its just not working. When I give permissions for audio it is still asking me for permission. |
@ErikSin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this flow is a little confusing.
When the user sets the permission in the settings, we should close the modal. This can be done in the listener:
useEffect(() => {
const subscription = AppState.addEventListener('focus', () =>
Audio.getPermissionsAsync().then(perm=>{
setPermissionData(perm)
if(perm.isGranted) closeModal()
}),
);
return () => subscription.remove();
}, []);
The problem with this, is the hook usePermissions
in ThumbnailAndActionTab
doesn't get updates. If we do what I suggested above: The user has set permission in the setting, permission is granted and the modal is closed automatically. But inThumbnailAndActionTab
permissionResponse === false
(because the hook doesn't track when permission are asked outside the app). Since permissionResponse === false
, the user will press the audio button, and the modal will open again even though they have the permission.
What needs to happen is the state needs to be tracked in the parent component with one hook const [permissionData, setPermissionData] = useState<PermissionResponse>();
Right now you are using 2 hooks: the usePermission
in the parent and useState<PermissionResponse>()
in the modal; Intead use useState<PermissionResponse>()
in the parent, and pass it values as props to the modal. And then the permissionData
will be synced between the parent and the modal, meaning that the modal will close when the setting have been changed AND the parent will know that, and not attempt to open the modal again
Okay, I thought we shouldn't have to close the modal after the user has set permission in the setting and permission is granted I thought we should stay in the same place and after he presses the |
Just for clarity, what should happen is that when they change their permissions in the setting, the modal should close and the user should be navigated to the audio page. Obviously that is out of scope for this PR, so we should just close the modal for this PR |
…e bottomSheet if permission was granted in settings
…-hot-fix-with-navigation