Skip to content

Commit

Permalink
dont use a favicon that isnt present
Browse files Browse the repository at this point in the history
  • Loading branch information
asktree committed Oct 2, 2023
1 parent 4b2ad58 commit 32aa4b1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
} from '@sqds/iframe-adapter'
import { WALLET_PROVIDERS } from '@utils/wallet-adapters'
import { tryParsePublicKey } from '@tools/core/pubkey'
import { useAsync } from 'react-async-hook'

const Notifications = dynamic(() => import('../components/Notification'), {
ssr: false,
Expand Down Expand Up @@ -131,6 +132,17 @@ export function AppContents(props: Props) {
symbol as string
)}/favicon.ico?v=${Date.now()}`

// check if a file actually exists at faviconUrl
const { result: faviconExists } = useAsync(
async () =>
faviconUrl
? fetch(faviconUrl)
.then((response) => response.status === 200)
.catch(() => false)
: false,
[faviconUrl]
)

useEffect(() => {
if (
realm &&
Expand Down Expand Up @@ -178,7 +190,7 @@ export function AppContents(props: Props) {
background-color: #17161c;
}
`}</style>
{faviconUrl ? (
{faviconUrl && faviconExists ? (
<>
<link rel="icon" href={faviconUrl} />
</>
Expand Down

0 comments on commit 32aa4b1

Please sign in to comment.