Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix browser refresh redirecting to /chat/new #210

Merged
merged 1 commit into from
May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/models/Conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions client/src/hooks/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down