Closed hotchemi closed 3 years ago
The issue is not fixed on this PR :sob:
But I investigated the issue and found the cause of problem:
After calling PermissionsRequester.launch
and permission is granted, PermissionResult.GRANTED
is emitted to the permissionRequestResult
.
After that, we call PermissionsRequester.launch
again, then requiresPermissions
is called 2 points below:
permissionRequestResult
has initial value which is emitted when permissions is granted at first. so when observe
at the next time, initial value (PermissionResult.GRANTED
) will be emitted to observer unexpectedly.
https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/0f9071451da607319a53b26193898ca08308185b/ktx/src/main/java/permissions/dispatcher/ktx/PermissionRequestViewModel.kt#L17-L19requiresPermissions
will be called here.
https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/0f9071451da607319a53b26193898ca08308185b/ktx/src/main/java/permissions/dispatcher/ktx/PermissionsRequesterImpl.kt#L26-L29From above, we can probably fix this issue in one of following ways:
cool! let me take a look again🙏
Thank you so much 🙏
For your reference, this commit can fix the issue: https://github.com/yt-tkhs/PermissionsDispatcher/commit/6b914ba4d6685672f2c8576dbce87a5d90aee01a (Fixed by observing PermissionResult only when permission is not granted. but maybe there are any bad side effects 🤔)
I've modified as 506d50524154b41d4e6485b2656751299069982a, let me merge!
Currently, we allow multiple observers to receive the permission change event but it might cause an unexpected issue.
ref: https://github.com/yt-tkhs/permissionsdispatcher-ktx-issue