From 6e2bab4175c685f68682af23b39002cac496ac19 Mon Sep 17 00:00:00 2001 From: btzr-io Date: Sun, 8 Aug 2021 00:48:03 -0500 Subject: [PATCH] stop calling window.open multiple times --- web/page/openInDesktop/view.jsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/web/page/openInDesktop/view.jsx b/web/page/openInDesktop/view.jsx index ae9f700c8..797e8d16a 100644 --- a/web/page/openInDesktop/view.jsx +++ b/web/page/openInDesktop/view.jsx @@ -18,18 +18,29 @@ const OpenInDesktop = (props: Props) => { const { match } = props; const { params } = match; const [title, setTitle] = React.useState('Loading...'); + const [claimUrl, setClaimUrl] = React.useState(null); + // Get claim url React.useEffect(() => { if (params) { try { const url = buildURI(params); - setTimeout(() => { - setTitle('Ready!'); - window.open(url, '_top'); - }, 1500); + if (url && claimUrl !== url) { + setClaimUrl(url); + } } catch {} } - }, [params]); + }, [params, claimUrl, setClaimUrl]); + + // Open url on external application + React.useEffect(() => { + if (claimUrl) { + setTimeout(() => { + setTitle('Ready!'); + window.open(claimUrl, '_top'); + }, 1500); + } + }, [claimUrl]); return (