Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(referral):multiple-click-error

Aswin Asoke836feab0ad0
diff --git a/web/apps/photos/src/components/sidebar/ReferralSettings.tsx b/web/apps/photos/src/components/sidebar/ReferralSettings.tsx
index d882b0fc53..8a05b1f34d 100644
--- a/web/apps/photos/src/components/sidebar/ReferralSettings.tsx
+++ b/web/apps/photos/src/components/sidebar/ReferralSettings.tsx
@@ -699,6 +699,7 @@ const InviteShareButton: React.FC<InviteShareButtonProps> = ({
}) => {
const { onGenericError } = useBaseContext();
const [copied, setCopied] = useState(false);
+ const shareInProgress = useRef(false);
const copiedTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(
undefined,
);
@@ -717,12 +718,16 @@ const InviteShareButton: React.FC<InviteShareButtonProps> = ({
});
if (typeof navigator.share == "function") {
+ if (shareInProgress.current) return;
+ shareInProgress.current = true;
try {
await navigator.share({ text });
} catch (e) {
if ((e as Error).name == "AbortError") return;
log.error("Failed to share referral invite", e);
onGenericError(e);
+ } finally {
+ shareInProgress.current = false;
}
return;
}