Skip to content

Commit 537c8af

Browse files
committed
fixup! Fix camera permissions race condition
1 parent 6020116 commit 537c8af

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/components/services/PermissionsManager.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,17 @@ export async function requestContactsPermission(
9393
export const checkAndRequestPermission =
9494
(permission: Permission): ThunkAction<Promise<PermissionStatus>> =>
9595
async dispatch => {
96-
const status: PermissionStatus = await check(permissionNames[permission])
96+
let status: PermissionStatus = await check(permissionNames[permission])
9797

98-
if (status !== 'denied') return status
99-
100-
const newStatus = await request(permissionNames[permission])
101-
if (newStatus !== status) {
102-
dispatch({
103-
type: 'PERMISSIONS/UPDATE',
104-
data: { [permission]: newStatus }
105-
})
98+
if (status === 'denied') {
99+
status = await request(permissionNames[permission])
106100
}
107-
return newStatus
101+
102+
dispatch({
103+
type: 'PERMISSIONS/UPDATE',
104+
data: { [permission]: status }
105+
})
106+
return status
108107
}
109108

110109
export const checkIfDenied = (status: PermissionStatus) =>

0 commit comments

Comments
 (0)