Skip to content

Commit

Permalink
Check permission existence in connect callbacks
Browse files Browse the repository at this point in the history
Even though we know the callbacks can’t be called
unless the component has a non-empty permission,
there is no way to statically guarantee it. Jump
Through the extra hoop to handle all possibilities.
  • Loading branch information
Shadowfiend committed Dec 11, 2021
1 parent e151fdb commit 6603a90
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ui/pages/DAppConnectRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ export default function DAppConnectRequest(): ReactElement {
const dispatch = useBackgroundDispatch()

const grant = useCallback(async () => {
await dispatch(grantPermission({ ...permission, state: "allow" }))
if (typeof permission !== "undefined") {
await dispatch(grantPermission({ ...permission, state: "allow" }))
}
window.close()
}, [dispatch, permission])

const deny = useCallback(async () => {
await dispatch(denyOrRevokePermission({ ...permission, state: "deny" }))
if (typeof permission !== "undefined") {
await dispatch(denyOrRevokePermission({ ...permission, state: "deny" }))
}
window.close()
}, [dispatch, permission])

Expand Down

0 comments on commit 6603a90

Please sign in to comment.