mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27: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) => {
|
||||
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(() => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useRef } from 'react';
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
import { jwtDecode, JwtPayload } from 'jwt-decode';
|
||||
|
||||
type AppleLoginResponse = {
|
||||
|
|
@ -94,6 +94,10 @@ const useAppleLogin = (): [() => Promise<AppleLoginResponse>, () => void] => {
|
|||
started.current = false;
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
return () => stop();
|
||||
}, []);
|
||||
|
||||
return [start, stop];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue