mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
fix browser refresh redirecting to /chat/new (#210)
This commit is contained in:
parent
d7b415837b
commit
3b4ed98c1d
2 changed files with 1 additions and 5 deletions
|
|
@ -3,7 +3,6 @@ const Conversation = require('./schema/convoSchema');
|
||||||
const { getMessages, deleteMessages } = require('./Message');
|
const { getMessages, deleteMessages } = require('./Message');
|
||||||
|
|
||||||
const getConvo = async (user, conversationId) => {
|
const getConvo = async (user, conversationId) => {
|
||||||
console.log('getConvo -> userId', user);
|
|
||||||
try {
|
try {
|
||||||
return await Conversation.findOne({ user, conversationId }).exec();
|
return await Conversation.findOne({ user, conversationId }).exec();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import {
|
||||||
TLoginUser
|
TLoginUser
|
||||||
} from '~/data-provider';
|
} from '~/data-provider';
|
||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import store from '~/store';
|
|
||||||
|
|
||||||
export type TAuthContext = {
|
export type TAuthContext = {
|
||||||
user: TUser | undefined,
|
user: TUser | undefined,
|
||||||
|
|
@ -47,8 +46,6 @@ const AuthContextProvider = ({ children }: { children: ReactNode }) => {
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const { newConversation } = store.useConversation();
|
|
||||||
|
|
||||||
const setUserContext = (userContext: TUserContext) => {
|
const setUserContext = (userContext: TUserContext) => {
|
||||||
const { token, isAuthenticated, user, redirect } = userContext;
|
const { token, isAuthenticated, user, redirect } = userContext;
|
||||||
if(user) {
|
if(user) {
|
||||||
|
|
@ -110,7 +107,7 @@ const AuthContextProvider = ({ children }: { children: ReactNode }) => {
|
||||||
const tokenFromCookie = getCookieValue('token');
|
const tokenFromCookie = getCookieValue('token');
|
||||||
if (tokenFromCookie) {
|
if (tokenFromCookie) {
|
||||||
// debugger;
|
// debugger;
|
||||||
setUserContext({ token: tokenFromCookie, isAuthenticated: true, user: userQuery.data, redirect: '/chat/new' })
|
setUserContext({ token: tokenFromCookie, isAuthenticated: true, user: userQuery.data })
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue