From 565728aacf7891a033980982bd894afedb3e9a92 Mon Sep 17 00:00:00 2001 From: Daniel D Orlando Date: Sun, 7 May 2023 16:08:21 -0700 Subject: [PATCH] fix browser refresh redirecting to /chat/new --- api/models/Conversation.js | 1 - client/src/hooks/AuthContext.tsx | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/api/models/Conversation.js b/api/models/Conversation.js index 2333ed67293..20470718668 100644 --- a/api/models/Conversation.js +++ b/api/models/Conversation.js @@ -3,7 +3,6 @@ const Conversation = require('./schema/convoSchema'); const { getMessages, deleteMessages } = require('./Message'); const getConvo = async (user, conversationId) => { - console.log('getConvo -> userId', user); try { return await Conversation.findOne({ user, conversationId }).exec(); } catch (error) { diff --git a/client/src/hooks/AuthContext.tsx b/client/src/hooks/AuthContext.tsx index bf0dfbee7ee..1d1075d28d8 100644 --- a/client/src/hooks/AuthContext.tsx +++ b/client/src/hooks/AuthContext.tsx @@ -10,7 +10,6 @@ import { TLoginUser } from '~/data-provider'; import { useNavigate, useLocation } from 'react-router-dom'; -import store from '~/store'; export type TAuthContext = { user: TUser | undefined, @@ -47,8 +46,6 @@ const AuthContextProvider = ({ children }: { children: ReactNode }) => { const location = useLocation(); - const { newConversation } = store.useConversation(); - const setUserContext = (userContext: TUserContext) => { const { token, isAuthenticated, user, redirect } = userContext; if(user) { @@ -110,7 +107,7 @@ const AuthContextProvider = ({ children }: { children: ReactNode }) => { const tokenFromCookie = getCookieValue('token'); if (tokenFromCookie) { // debugger; - setUserContext({ token: tokenFromCookie, isAuthenticated: true, user: userQuery.data, redirect: '/chat/new' }) + setUserContext({ token: tokenFromCookie, isAuthenticated: true, user: userQuery.data }) } else { navigate('/login');