mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
feat: search in progress
This commit is contained in:
parent
9995a159aa
commit
6d2f3361d0
6 changed files with 84 additions and 24 deletions
|
|
@ -15,29 +15,27 @@ const App = () => {
|
|||
const { messages, messageTree } = useSelector((state) => state.messages);
|
||||
const { user } = useSelector((state) => state.user);
|
||||
const { title } = useSelector((state) => state.convo);
|
||||
const { conversationId } = useSelector((state) => state.convo);
|
||||
const [ navVisible, setNavVisible ]= useState(false)
|
||||
useDocumentTitle(title);
|
||||
|
||||
useEffect(() => {
|
||||
axios.get('/api/me', {
|
||||
timeout: 1000,
|
||||
withCredentials: true
|
||||
}).then((res) => {
|
||||
return res.data
|
||||
}).then((user) => {
|
||||
if (user)
|
||||
dispatch(setUser(user))
|
||||
else {
|
||||
console.log('Not login!')
|
||||
window.location.href = "/auth/login";
|
||||
useEffect(async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/me', {
|
||||
timeout: 1000,
|
||||
withCredentials: true
|
||||
});
|
||||
const user = response.data;
|
||||
if (user) {
|
||||
dispatch(setUser(user));
|
||||
} else {
|
||||
console.log('Not login!');
|
||||
window.location.href = '/auth/login';
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error(error)
|
||||
console.log('Not login!')
|
||||
window.location.href = "/auth/login";
|
||||
})
|
||||
// setUser
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.log('Not login!');
|
||||
window.location.href = '/auth/login';
|
||||
}
|
||||
}, [])
|
||||
|
||||
if (user)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import NewChat from './NewChat';
|
|||
import Spinner from '../svg/Spinner';
|
||||
import Conversations from '../Conversations';
|
||||
import NavLinks from './NavLinks';
|
||||
import useDidMountEffect from '~/hooks/useDidMountEffect';
|
||||
import { swr } from '~/utils/fetchers';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { increasePage, decreasePage, setPage, setConvos, setPages } from '~/store/convoSlice';
|
||||
|
|
@ -11,7 +10,7 @@ import { increasePage, decreasePage, setPage, setConvos, setPages } from '~/stor
|
|||
export default function Nav({ navVisible, setNavVisible }) {
|
||||
const dispatch = useDispatch();
|
||||
const [isHovering, setIsHovering] = useState(false);
|
||||
const { conversationId, convos, pages, pageNumber, refreshConvoHint } = useSelector(
|
||||
const { conversationId, convos, search, pages, pageNumber, refreshConvoHint } = useSelector(
|
||||
(state) => state.convo
|
||||
);
|
||||
const onSuccess = (data) => {
|
||||
|
|
@ -25,7 +24,7 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
}
|
||||
};
|
||||
|
||||
const { data, isLoading, mutate } = swr(`/api/convos?pageNumber=${pageNumber}`, onSuccess, {
|
||||
const { data, isLoading, mutate } = swr(`/api/${search ? 'search?q=' : `convos?pageNumber=${pageNumber}`}`, onSuccess, {
|
||||
revalidateOnMount: false
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const initialState = {
|
|||
pageNumber: 1,
|
||||
pages: 1,
|
||||
refreshConvoHint: 0,
|
||||
search: false,
|
||||
convos: [],
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue