stop calling window.open multiple times
This commit is contained in:
parent
47f7d0c7e3
commit
6e2bab4175
1 changed files with 16 additions and 5 deletions
|
@ -18,18 +18,29 @@ const OpenInDesktop = (props: Props) => {
|
||||||
const { match } = props;
|
const { match } = props;
|
||||||
const { params } = match;
|
const { params } = match;
|
||||||
const [title, setTitle] = React.useState('Loading...');
|
const [title, setTitle] = React.useState('Loading...');
|
||||||
|
const [claimUrl, setClaimUrl] = React.useState(null);
|
||||||
|
|
||||||
|
// Get claim url
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (params) {
|
if (params) {
|
||||||
try {
|
try {
|
||||||
const url = buildURI(params);
|
const url = buildURI(params);
|
||||||
setTimeout(() => {
|
if (url && claimUrl !== url) {
|
||||||
setTitle('Ready!');
|
setClaimUrl(url);
|
||||||
window.open(url, '_top');
|
}
|
||||||
}, 1500);
|
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
}, [params]);
|
}, [params, claimUrl, setClaimUrl]);
|
||||||
|
|
||||||
|
// Open url on external application
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (claimUrl) {
|
||||||
|
setTimeout(() => {
|
||||||
|
setTitle('Ready!');
|
||||||
|
window.open(claimUrl, '_top');
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
}, [claimUrl]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
|
|
Loading…
Add table
Reference in a new issue