mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
@@ -18,7 +18,7 @@ const AddButton = memo(() => {
|
||||
createGroupChatMenuItem,
|
||||
createPageMenuItem,
|
||||
createAgent,
|
||||
isValidatingAgent,
|
||||
isMutatingAgent,
|
||||
isCreatingGroup,
|
||||
} = useCreateMenuItems();
|
||||
|
||||
@@ -39,7 +39,7 @@ const AddButton = memo(() => {
|
||||
<Flexbox horizontal>
|
||||
<ActionIcon
|
||||
icon={CreateBotIcon}
|
||||
loading={isValidatingAgent || isCreatingGroup}
|
||||
loading={isMutatingAgent || isCreatingGroup}
|
||||
onClick={handleMainIconClick}
|
||||
size={DESKTOP_HEADER_ICON_SIZE}
|
||||
title={tChat('newAgent')}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { BotIcon, FileTextIcon, FolderCogIcon, FolderPlus } from 'lucide-react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import useSWRMutation from 'swr/mutation';
|
||||
|
||||
import { useGroupTemplates } from '@/components/ChatGroupWizard/templates';
|
||||
import { DEFAULT_CHAT_GROUP_CHAT_CONFIG } from '@/const/settings';
|
||||
@@ -51,22 +52,22 @@ export const useCreateMenuItems = () => {
|
||||
const [isCreatingSessionGroup, setIsCreatingSessionGroup] = useState(false);
|
||||
|
||||
// SWR-based agent creation with auto navigation to profile
|
||||
const { mutate: mutateAgent, isValidating: isValidatingAgent } = useActionSWR(
|
||||
const { trigger: mutateAgent, isMutating: isMutatingAgent } = useSWRMutation(
|
||||
'agent.createAgent',
|
||||
async () => {
|
||||
const result = await storeCreateAgent({});
|
||||
navigate(`/agent/${result.agentId}/profile`);
|
||||
return result;
|
||||
},
|
||||
{
|
||||
onSuccess: async () => {
|
||||
onSuccess: async (result) => {
|
||||
navigate(`/agent/${result.agentId}/profile`);
|
||||
await refreshAgentList();
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// SWR-based group creation with auto navigation to profile
|
||||
const { mutate: mutateGroup, isValidating: isValidatingGroup } = useActionSWR(
|
||||
const { trigger: mutateGroup, isMutating: isMutatingGroup } = useSWRMutation(
|
||||
'group.createGroup',
|
||||
async () => {
|
||||
const groupId = await createGroup(
|
||||
@@ -77,11 +78,11 @@ export const useCreateMenuItems = () => {
|
||||
[],
|
||||
true, // silent mode - don't switch session, we'll navigate instead
|
||||
);
|
||||
navigate(`/group/${groupId}/profile`);
|
||||
return groupId;
|
||||
},
|
||||
{
|
||||
onSuccess: async () => {
|
||||
onSuccess: async (groupId) => {
|
||||
navigate(`/group/${groupId}/profile`);
|
||||
await refreshAgentList();
|
||||
await loadGroups();
|
||||
},
|
||||
@@ -329,7 +330,7 @@ export const useCreateMenuItems = () => {
|
||||
// Loading states
|
||||
isCreatingGroup,
|
||||
isCreatingSessionGroup,
|
||||
isLoading: isValidatingAgent || isValidatingGroup || isCreatingGroup || isCreatingSessionGroup,
|
||||
isValidatingAgent,
|
||||
isLoading: isMutatingAgent || isMutatingGroup || isCreatingGroup || isCreatingSessionGroup,
|
||||
isMutatingAgent,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user