mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 21:28:50 +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
|
|
@ -1,12 +1,11 @@
|
|||
import { useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { useGetEndpointsQuery } from 'librechat-data-provider';
|
||||
import { Settings } from 'lucide-react';
|
||||
import { DropdownMenuRadioItem } from '~/components';
|
||||
import { Icon } from '~/components/Endpoints';
|
||||
import { SetKeyDialog } from '../SetKeyDialog';
|
||||
import { useLocalize } from '~/hooks';
|
||||
|
||||
import store from '~/store';
|
||||
import { cn, alternateName } from '~/utils';
|
||||
|
||||
export default function ModelItem({
|
||||
|
|
@ -19,7 +18,7 @@ export default function ModelItem({
|
|||
isSelected: boolean;
|
||||
}) {
|
||||
const [isDialogOpen, setDialogOpen] = useState(false);
|
||||
const endpointsConfig = useRecoilValue(store.endpointsConfig);
|
||||
const { data: endpointsConfig } = useGetEndpointsQuery();
|
||||
|
||||
const icon = Icon({
|
||||
size: 20,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
import { Trash2 } from 'lucide-react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRecoilValue, useRecoilState } from 'recoil';
|
||||
import { useDeletePresetMutation, useCreatePresetMutation } from 'librechat-data-provider';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import {
|
||||
useDeletePresetMutation,
|
||||
useCreatePresetMutation,
|
||||
useGetEndpointsQuery,
|
||||
} from 'librechat-data-provider';
|
||||
import { Icon, EditPresetDialog } from '~/components/Endpoints';
|
||||
import EndpointItems from './EndpointItems';
|
||||
import PresetItems from './PresetItems';
|
||||
|
|
@ -23,7 +27,7 @@ import {
|
|||
TooltipContent,
|
||||
} from '~/components/ui/';
|
||||
import DialogTemplate from '~/components/ui/DialogTemplate';
|
||||
import { cn, cleanupPreset } from '~/utils';
|
||||
import { cn, cleanupPreset, mapEndpoints } from '~/utils';
|
||||
import { useLocalize, useLocalStorage, useConversation, useDefaultConvo } from '~/hooks';
|
||||
import store from '~/store';
|
||||
|
||||
|
|
@ -37,7 +41,10 @@ export default function NewConversationMenu() {
|
|||
const [preset, setPreset] = useState(false);
|
||||
const [conversation, setConversation] = useRecoilState(store.conversation) ?? {};
|
||||
const [messages, setMessages] = useRecoilState(store.messages);
|
||||
const availableEndpoints = useRecoilValue(store.availableEndpoints);
|
||||
|
||||
const { data: availableEndpoints } = useGetEndpointsQuery({
|
||||
select: mapEndpoints,
|
||||
});
|
||||
|
||||
const [presets, setPresets] = useRecoilState(store.presets);
|
||||
const modularEndpoints = new Set(['gptPlugins', 'anthropic', 'google', 'openAI']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue