mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
Refactor: replace endpointsConfig recoil store with react query (#1085)
This commit is contained in:
parent
7d6a1d260f
commit
4073b7d05d
15 changed files with 83 additions and 49 deletions
|
|
@ -3,7 +3,6 @@ import { useEffect, useState } from 'react';
|
|||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import {
|
||||
useGetEndpointsQuery,
|
||||
useGetModelsQuery,
|
||||
useGetPresetsQuery,
|
||||
useGetSearchEnabledQuery,
|
||||
|
|
@ -26,10 +25,8 @@ export default function Root() {
|
|||
|
||||
const setPresets = useSetRecoilState(store.presets);
|
||||
const setIsSearchEnabled = useSetRecoilState(store.isSearchEnabled);
|
||||
const setEndpointsConfig = useSetRecoilState(store.endpointsConfig);
|
||||
const setModelsConfig = useSetRecoilState(store.modelsConfig);
|
||||
|
||||
const endpointsQuery = useGetEndpointsQuery();
|
||||
const searchEnabledQuery = useGetSearchEnabledQuery({ enabled: isAuthenticated });
|
||||
const modelsQuery = useGetModelsQuery({ enabled: isAuthenticated });
|
||||
const presetsQuery = useGetPresetsQuery({ enabled: !!user });
|
||||
|
|
@ -38,14 +35,6 @@ export default function Root() {
|
|||
localStorage.setItem('navVisible', JSON.stringify(navVisible));
|
||||
}, [navVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (endpointsQuery.data) {
|
||||
setEndpointsConfig(endpointsQuery.data);
|
||||
} else if (endpointsQuery.isError) {
|
||||
console.error('Failed to get endpoints', endpointsQuery.error);
|
||||
}
|
||||
}, [endpointsQuery.data, endpointsQuery.isError]);
|
||||
|
||||
useEffect(() => {
|
||||
if (modelsQuery.data) {
|
||||
setModelsConfig(modelsQuery.data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue