|
1 | | -import React, { useEffect, useState } from 'react'; |
2 | | -import { FirebaseAuthentication } from '@capacitor-firebase/authentication'; |
| 1 | +import { useState } from 'react'; |
3 | 2 | import { Capacitor } from '@capacitor/core'; |
4 | | -import authStore from 'learn-card-base/stores/authStore'; |
5 | | -import { SocialLoginTypes } from 'learn-card-base/hooks/useSocialLogins'; |
6 | | -import { LOGIN_REDIRECTS } from 'learn-card-base/constants/redirects'; |
7 | | -import { BrandingEnum } from 'learn-card-base'; |
8 | | -import { pushUtilities } from 'learn-card-base'; |
| 3 | +import { useHistory } from 'react-router-dom'; |
| 4 | +import { FirebaseAuthentication } from '@capacitor-firebase/authentication'; |
| 5 | + |
9 | 6 | import { auth } from '../firebase/firebase'; |
10 | | -import { useWeb3AuthSFA, useWallet, useToast, ToastTypeEnum } from 'learn-card-base'; |
11 | | -import useSQLiteStorage from 'learn-card-base/hooks/useSQLiteStorage'; |
| 7 | +import authStore from 'learn-card-base/stores/authStore'; |
| 8 | + |
| 9 | +import { |
| 10 | + useModal, |
| 11 | + BrandingEnum, |
| 12 | + pushUtilities, |
| 13 | + LOGIN_REDIRECTS, |
| 14 | + SocialLoginTypes, |
| 15 | + useWeb3AuthSFA, |
| 16 | + useToast, |
| 17 | + useWallet, |
| 18 | + ToastTypeEnum, |
| 19 | + useSQLiteStorage, |
| 20 | +} from 'learn-card-base'; |
12 | 21 | import { useQueryClient } from '@tanstack/react-query'; |
13 | | -import { IonLoading } from '@ionic/react'; |
14 | 22 |
|
15 | 23 | const useLogout = () => { |
16 | | - const [isLoggingOut, setIsLoggingOut] = useState<boolean>(false); |
17 | | - const { logout, loggingOut: web3AuthLoggingOut } = useWeb3AuthSFA(); |
18 | | - const { clearDB } = useSQLiteStorage(); |
19 | 24 | const firebaseAuth = auth(); |
| 25 | + const history = useHistory(); |
20 | 26 | const { initWallet } = useWallet(); |
21 | | - const { presentToast } = useToast(); |
22 | 27 | const queryClient = useQueryClient(); |
| 28 | + const { clearDB } = useSQLiteStorage(); |
| 29 | + const { logout, loggingOut: web3AuthLoggingOut } = useWeb3AuthSFA(); |
| 30 | + |
| 31 | + const { closeAllModals } = useModal(); |
| 32 | + const { presentToast } = useToast(); |
| 33 | + |
| 34 | + const [isLoggingOut, setIsLoggingOut] = useState<boolean>(false); |
23 | 35 |
|
24 | 36 | const handleLogout = async ( |
25 | 37 | branding: BrandingEnum, |
@@ -82,7 +94,12 @@ const useLogout = () => { |
82 | 94 | console.error(e); |
83 | 95 | } |
84 | 96 |
|
85 | | - await logout(redirectUrl); |
| 97 | + closeAllModals(); |
| 98 | + |
| 99 | + await logout(); |
| 100 | + |
| 101 | + // handle redirect from within LCA over web3Auth redirect |
| 102 | + history.push(redirectUrl); |
86 | 103 | } catch (e) { |
87 | 104 | console.error('There was an issue logging out', e); |
88 | 105 | setIsLoggingOut(false); |
|
0 commit comments