From c6c352ec2bfe64b9514ad5dadf2678270261d4da Mon Sep 17 00:00:00 2001 From: prathameshkurunkar7 Date: Fri, 29 Mar 2024 16:12:55 +0530 Subject: [PATCH] feat(mobile): all login options are not shown after logout --- mobile/src/pages/auth/Login.tsx | 10 ++++------ mobile/src/utils/auth/UserProvider.tsx | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/mobile/src/pages/auth/Login.tsx b/mobile/src/pages/auth/Login.tsx index 0c7a05ee1..1aed76e9b 100644 --- a/mobile/src/pages/auth/Login.tsx +++ b/mobile/src/pages/auth/Login.tsx @@ -24,12 +24,8 @@ export const Login = (props: ActiveScreenProps) => { }) // GET call for Login Context (settings for social logins, email link etc) const { data: loginContext, mutate } = useFrappeGetCall('raven.api.login.get_context', { - "redirect-to": "/raven" - }, 'raven.api.login.get_context', { - revalidateIfStale: false, - revalidateOnReconnect: false, - revalidateOnFocus: false - }) + "redirect-to": "/raven_mobile" + }, 'raven.api.login.get_context') const [error, setError] = useState(null) const { login } = useFrappeAuth() @@ -58,6 +54,8 @@ export const Login = (props: ActiveScreenProps) => { } } + console.log(loginContext) + return ( <>
diff --git a/mobile/src/utils/auth/UserProvider.tsx b/mobile/src/utils/auth/UserProvider.tsx index eba2d054e..5118d57e0 100644 --- a/mobile/src/utils/auth/UserProvider.tsx +++ b/mobile/src/utils/auth/UserProvider.tsx @@ -28,15 +28,19 @@ export const UserProvider: FC = ({ children }) => { const isLoggedIn = currentUser !== undefined && currentUser !== null && currentUser !== "Guest" const handleLogout = async () => { - return logout() - .then(() => { - //Clear cache on logout - return mutate(() => true, undefined, false) - }) - .then(() => { - // @ts-expect-error - window.frappePushNotification?.disableNotification() - }) + // @ts-expect-error + window.frappePushNotification?.disableNotification() + .then(() => logout()) + .then(() => { + //Clear cache on logout + return mutate((key) => { + if (key === 'raven.api.login.get_context'){ + return false + } + return true + }, undefined, false) + }) + } const handleLogin = async (username: string, password: string) => {