From e122daf2f168abbe129d433a15de00d9f8ab8287 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Tue, 3 Dec 2024 12:35:31 +0100 Subject: [PATCH] Extract named logout function --- src/context/SessionContext.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/context/SessionContext.tsx b/src/context/SessionContext.tsx index a2eed4e22..0ec5c08a4 100644 --- a/src/context/SessionContext.tsx +++ b/src/context/SessionContext.tsx @@ -25,18 +25,18 @@ export const SessionContextProvider = ({ children }) => { const api = useApi(isOnline); const keystore = useLocalStorageKeystore(); + const logout = async () => { + // Clear URL parameters + sessionStorage.setItem('freshLogin', 'true'); + api.clearSession(); + await keystore.close(); + }; + const value: SessionContextValue = { api, isLoggedIn: api.isLoggedIn() && keystore.isOpen(), keystore, - logout: async () => { - - // Clear URL parameters - sessionStorage.setItem('freshLogin', 'true'); - api.clearSession(); - await keystore.close(); - - }, + logout, }; return (