Skip to content

Commit 90f467b

Browse files
authored
fix(web): at most download once (#1106)
1 parent d8cded9 commit 90f467b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web/flat-web/src/pages/JoinPage/JoinPageMobile.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logoSVG from "./icons/logo-sm.svg";
22

3-
import React, { useCallback, useEffect, useState } from "react";
3+
import React, { useCallback, useEffect, useRef, useState } from "react";
44
import { useTranslation } from "react-i18next";
55
import { isAndroid } from "react-device-detect";
66
import { useWindowFocus } from "./use-window-focus";
@@ -25,6 +25,7 @@ export default function JoinPageMobile({
2525
const [isCheckingApp, setCheckApp] = useState(false);
2626
const isFocus = useWindowFocus();
2727
const isUnmounted = useIsUnMounted();
28+
const isDownloaded = useRef(false);
2829

2930
const openApp = useCallback(() => {
3031
window.location.href = `x-agora-flat-client://joinRoom?roomUUID=${roomUUID}`;
@@ -36,6 +37,7 @@ export default function JoinPageMobile({
3637
}, [roomUUID, isUnmounted]);
3738

3839
const download = useCallback(() => {
40+
isDownloaded.current = true;
3941
if (isAndroid) {
4042
window.open(AndroidApkUrl);
4143
} else {
@@ -44,7 +46,7 @@ export default function JoinPageMobile({
4446
}, []);
4547

4648
useEffect(() => {
47-
if (isCheckingApp) {
49+
if (isCheckingApp && !isDownloaded.current) {
4850
// if 5 seconds later the page is still in focus,
4951
// then maybe the app is not opened.
5052
if (isFocus) {

0 commit comments

Comments
 (0)