1
1
import logoSVG from "./icons/logo-sm.svg" ;
2
2
3
- import React , { useCallback , useEffect , useState } from "react" ;
3
+ import React , { useCallback , useEffect , useRef , useState } from "react" ;
4
4
import { useTranslation } from "react-i18next" ;
5
5
import { isAndroid } from "react-device-detect" ;
6
6
import { useWindowFocus } from "./use-window-focus" ;
@@ -25,6 +25,7 @@ export default function JoinPageMobile({
25
25
const [ isCheckingApp , setCheckApp ] = useState ( false ) ;
26
26
const isFocus = useWindowFocus ( ) ;
27
27
const isUnmounted = useIsUnMounted ( ) ;
28
+ const isDownloaded = useRef ( false ) ;
28
29
29
30
const openApp = useCallback ( ( ) => {
30
31
window . location . href = `x-agora-flat-client://joinRoom?roomUUID=${ roomUUID } ` ;
@@ -36,6 +37,7 @@ export default function JoinPageMobile({
36
37
} , [ roomUUID , isUnmounted ] ) ;
37
38
38
39
const download = useCallback ( ( ) => {
40
+ isDownloaded . current = true ;
39
41
if ( isAndroid ) {
40
42
window . open ( AndroidApkUrl ) ;
41
43
} else {
@@ -44,7 +46,7 @@ export default function JoinPageMobile({
44
46
} , [ ] ) ;
45
47
46
48
useEffect ( ( ) => {
47
- if ( isCheckingApp ) {
49
+ if ( isCheckingApp && ! isDownloaded . current ) {
48
50
// if 5 seconds later the page is still in focus,
49
51
// then maybe the app is not opened.
50
52
if ( isFocus ) {
0 commit comments