mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 11:42:05 +00:00
refactor(useapplelogin): handle error cases
This commit is contained in:
parent
3aac148258
commit
303dd9858b
2 changed files with 10 additions and 2 deletions
|
|
@ -129,7 +129,11 @@ const Intro = ({ queryParams }) => {
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
closeLoaderModal();
|
closeLoaderModal();
|
||||||
dispatch({ type: 'error', error: error.message });
|
if (error.error === 'popup_closed_by_user') {
|
||||||
|
dispatch({ type: 'error', error: 'Apple login popup was closed.' });
|
||||||
|
} else {
|
||||||
|
dispatch({ type: 'error', error: error.error });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
const cancelLoginWithApple = React.useCallback(() => {
|
const cancelLoginWithApple = React.useCallback(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useRef } from 'react';
|
import { useCallback, useEffect, useRef } from 'react';
|
||||||
import { jwtDecode, JwtPayload } from 'jwt-decode';
|
import { jwtDecode, JwtPayload } from 'jwt-decode';
|
||||||
|
|
||||||
type AppleLoginResponse = {
|
type AppleLoginResponse = {
|
||||||
|
|
@ -94,6 +94,10 @@ const useAppleLogin = (): [() => Promise<AppleLoginResponse>, () => void] => {
|
||||||
started.current = false;
|
started.current = false;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => stop();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return [start, stop];
|
return [start, stop];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue