Skip to content

Commit d4a5f38

Browse files
authored
fix: mf-6723 prevent multiple clicks on welcome screen agree button (#12241)
disable the 'agree' button on the welcome screen while the `handleAgree` function is executing to prevent multiple clicks and potential issues.
1 parent 4397de9 commit d4a5f38

File tree

1 file changed

+4
-3
lines changed
  • packages/mask/dashboard/pages/SetupPersona/Welcome

1 file changed

+4
-3
lines changed

packages/mask/dashboard/pages/SetupPersona/Welcome/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { Trans } from '@lingui/react/macro'
44
import { DashboardRoutes, EnhanceableSite, userGuideStatus } from '@masknet/shared-base'
55
import { makeStyles, useCustomSnackbar } from '@masknet/theme'
66
import { Checkbox, FormControlLabel, Typography } from '@mui/material'
7-
import { memo, useCallback, useState } from 'react'
7+
import { memo, useState } from 'react'
88
import { useNavigate, useSearchParams } from 'react-router-dom'
9+
import { useAsyncFn } from 'react-use'
910
import { requestPermissionFromExtensionPage } from '../../../../shared-ui/index.js'
1011
import { definedSiteAdaptors } from '../../../../shared/site-adaptors/definitions.js'
1112
import { PrimaryButton } from '../../../components/PrimaryButton/index.js'
@@ -57,7 +58,7 @@ export const Component = memo(function Welcome() {
5758
const navigate = useNavigate()
5859

5960
const snackbar = useCustomSnackbar()
60-
const handleAgree = useCallback(async () => {
61+
const [{ loading }, handleAgree] = useAsyncFn(async () => {
6162
if (allowedToCollect) {
6263
Services.Settings.setTelemetryEnabled(true)
6364
}
@@ -108,7 +109,7 @@ export const Component = memo(function Welcome() {
108109
<SecondaryButton variant="rounded" width="125px" size="large" onClick={() => window.close()}>
109110
<Trans>Cancel</Trans>
110111
</SecondaryButton>
111-
<PrimaryButton width="125px" size="large" color="primary" onClick={handleAgree}>
112+
<PrimaryButton width="125px" size="large" color="primary" onClick={handleAgree} disabled={loading}>
112113
<Trans>Agree</Trans>
113114
</PrimaryButton>
114115
</div>

0 commit comments

Comments
 (0)