refactor: remove unused avatar upload mutation field and add informational toast for success

This commit is contained in:
Danny Avila 2025-07-15 21:50:07 -04:00
parent 9f68b03e8c
commit 04af67951b
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
4 changed files with 6 additions and 10 deletions

View file

@ -2,10 +2,9 @@ import * as Popover from '@radix-ui/react-popover';
import { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from '@tanstack/react-query';
import { import {
fileConfig as defaultFileConfig,
QueryKeys, QueryKeys,
defaultOrderQuery,
mergeFileConfig, mergeFileConfig,
fileConfig as defaultFileConfig,
} from 'librechat-data-provider'; } from 'librechat-data-provider';
import type { UseMutationResult } from '@tanstack/react-query'; import type { UseMutationResult } from '@tanstack/react-query';
import type { import type {
@ -51,12 +50,11 @@ function Avatar({
onMutate: () => { onMutate: () => {
setProgress(0.4); setProgress(0.4);
}, },
onSuccess: (data, vars) => { onSuccess: (data) => {
if (vars.postCreation === false) { if (lastSeenCreatedId.current !== createMutation.data?.id) {
showToast({ message: localize('com_ui_upload_success') });
} else if (lastSeenCreatedId.current !== createMutation.data?.id) {
lastSeenCreatedId.current = createMutation.data?.id ?? ''; lastSeenCreatedId.current = createMutation.data?.id ?? '';
} }
showToast({ message: localize('com_ui_upload_agent_avatar') });
setInput(null); setInput(null);
const newUrl = data.avatar?.filepath ?? ''; const newUrl = data.avatar?.filepath ?? '';
@ -143,7 +141,6 @@ function Avatar({
uploadAvatar({ uploadAvatar({
agent_id: createMutation.data.id, agent_id: createMutation.data.id,
postCreation: true,
formData, formData,
}); });
} }

View file

@ -194,8 +194,7 @@ export const useUploadAgentAvatarMutation = (
unknown // context unknown // context
> => { > => {
return useMutation([MutationKeys.agentAvatarUpload], { return useMutation([MutationKeys.agentAvatarUpload], {
mutationFn: ({ postCreation, ...variables }: t.AgentAvatarVariables) => mutationFn: (variables: t.AgentAvatarVariables) => dataService.uploadAgentAvatar(variables),
dataService.uploadAgentAvatar(variables),
...(options || {}), ...(options || {}),
}); });
}; };

View file

@ -1059,6 +1059,7 @@
"com_ui_update_mcp_error": "There was an error creating or updating the MCP.", "com_ui_update_mcp_error": "There was an error creating or updating the MCP.",
"com_ui_update_mcp_success": "Successfully created or updated MCP", "com_ui_update_mcp_success": "Successfully created or updated MCP",
"com_ui_upload": "Upload", "com_ui_upload": "Upload",
"com_ui_upload_agent_avatar": "Successfully updated agent avatar",
"com_ui_upload_code_files": "Upload for Code Interpreter", "com_ui_upload_code_files": "Upload for Code Interpreter",
"com_ui_upload_delay": "Uploading \"{{0}}\" is taking more time than anticipated. Please wait while the file finishes indexing for retrieval.", "com_ui_upload_delay": "Uploading \"{{0}}\" is taking more time than anticipated. Please wait while the file finishes indexing for retrieval.",
"com_ui_upload_error": "There was an error uploading your file", "com_ui_upload_error": "There was an error uploading your file",

View file

@ -109,7 +109,6 @@ export type DeleteActionOptions = MutationOptions<void, DeleteActionVariables>;
export type AgentAvatarVariables = { export type AgentAvatarVariables = {
agent_id: string; agent_id: string;
formData: FormData; formData: FormData;
postCreation?: boolean;
}; };
export type UpdateAgentActionVariables = { export type UpdateAgentActionVariables = {