Skip to content

Commit

Permalink
Add clipboard check
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Sep 9, 2024
1 parent 2ddaf17 commit ad0cd6e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion components/views/ScanConnect/ScanConnectDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useWcUri } from '../../../hooks/useWcUri'
import { useWalletHistory } from '../../../hooks/useWalletHistory'
import { handleCancel } from '../../../helpers/window'
import { ViewContainer } from '../../layout/ViewContainer'
import { useEffect, useState } from 'react'

interface ScanConnectDesktopProps {
wallet: Wallet
Expand All @@ -23,6 +24,16 @@ export default function ScanConnectDesktop({
handleCancel()
})

const [isClipboardAllowed, setIsClipboardAllowed] = useState(true)

useEffect(() => {
navigator.permissions
.query({ name: 'clipboard-write' as PermissionName })
.then(result => {
setIsClipboardAllowed(result.state === 'granted')
})
}, [])

if (connecting) {
return (
<ViewContainer
Expand All @@ -43,7 +54,9 @@ export default function ScanConnectDesktop({
>
<Flex justifyContent="space-between" width="100%" alignItems="center">
<Text textStyle="body2">Scan in the {wallet.name} app to connect</Text>
<CopyButton text={uri} />
{isClipboardAllowed && (
<CopyButton text={uri} disabled={!uri || isLoading} />
)}
</Flex>

<Box padding={3} borderRadius="0.75rem" borderWidth="1px" bg="white">
Expand Down

0 comments on commit ad0cd6e

Please sign in to comment.