mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-08 11:38:51 +01:00
feat: Implement Default Preset Selection for Conversations 📌 (#1275)
* fix: type issues with icons * refactor: use react query for presets, show toasts on preset crud, refactor mutations, remove presetsQuery from Root (breaking change) * refactor: change preset titling * refactor: update preset schemas and methods for necessary new properties `order` and `defaultPreset` * feat: add `defaultPreset` Recoil value * refactor(getPresetTitle): make logic cleaner and more concise * feat: complete UI portion of defaultPreset feature, with animations added to preset items * chore: remove console.logs() * feat: complete default preset handling * refactor: remove user sensitive values on logout * fix: allow endpoint selection without default preset overwriting
This commit is contained in:
parent
fdb65366d7
commit
ca64efec1b
32 changed files with 681 additions and 270 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
} from '@tanstack/react-query';
|
||||
import * as t from './types';
|
||||
import * as s from './schemas';
|
||||
import * as p from './types/presets';
|
||||
import * as dataService from './data-service';
|
||||
import request from './request';
|
||||
import { QueryKeys } from './keys';
|
||||
|
|
@ -276,7 +277,7 @@ export const useGetModelsQuery = (
|
|||
};
|
||||
|
||||
export const useCreatePresetMutation = (): UseMutationResult<
|
||||
s.TPreset[],
|
||||
s.TPreset,
|
||||
unknown,
|
||||
s.TPreset,
|
||||
unknown
|
||||
|
|
@ -290,7 +291,7 @@ export const useCreatePresetMutation = (): UseMutationResult<
|
|||
};
|
||||
|
||||
export const useUpdatePresetMutation = (): UseMutationResult<
|
||||
s.TPreset[],
|
||||
s.TPreset,
|
||||
unknown,
|
||||
s.TPreset,
|
||||
unknown
|
||||
|
|
@ -315,13 +316,13 @@ export const useGetPresetsQuery = (
|
|||
};
|
||||
|
||||
export const useDeletePresetMutation = (): UseMutationResult<
|
||||
s.TPreset[],
|
||||
p.PresetDeleteResponse,
|
||||
unknown,
|
||||
s.TPreset | object,
|
||||
s.TPreset | undefined,
|
||||
unknown
|
||||
> => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation((payload: s.TPreset | object) => dataService.deletePreset(payload), {
|
||||
return useMutation((payload: s.TPreset | undefined) => dataService.deletePreset(payload), {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries([QueryKeys.presets]);
|
||||
},
|
||||
|
|
@ -369,6 +370,9 @@ export const useLoginUserMutation = (): UseMutationResult<
|
|||
return useMutation((payload: t.TLoginUser) => dataService.login(payload), {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries([QueryKeys.user]);
|
||||
queryClient.invalidateQueries([QueryKeys.presets]);
|
||||
queryClient.invalidateQueries([QueryKeys.conversation]);
|
||||
queryClient.invalidateQueries([QueryKeys.allConversations]);
|
||||
},
|
||||
onMutate: () => {
|
||||
queryClient.invalidateQueries([QueryKeys.models]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue