mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
fix(useapplelogin): add timeout for close
This commit is contained in:
parent
52dc7722ad
commit
922de40134
1 changed files with 14 additions and 0 deletions
|
|
@ -52,7 +52,17 @@ const useAppleLogin = (): [() => Promise<AppleLoginResponse>, () => void] => {
|
|||
usePopup: true,
|
||||
});
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
if (started.current) {
|
||||
started.current = false;
|
||||
reject(new Error('Apple login popup was closed'));
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
window.AppleID.auth.signIn().then((response: AppleSignInResponse) => {
|
||||
clearTimeout(timeoutId);
|
||||
started.current = false;
|
||||
|
||||
if (response.authorization) {
|
||||
try {
|
||||
const idToken = response.authorization.id_token;
|
||||
|
|
@ -84,6 +94,10 @@ const useAppleLogin = (): [() => Promise<AppleLoginResponse>, () => void] => {
|
|||
} else {
|
||||
reject(new Error('No authorization received from Apple'));
|
||||
}
|
||||
}).catch((error) => {
|
||||
clearTimeout(timeoutId);
|
||||
started.current = false;
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
|
|
|
|||
Loading…
Reference in a new issue