mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 18:39:06 +08:00
refactor(ui): remove unused UI elements and commented code
clean up UI by removing unused text spans and commented out code remove unused timer functionality from AgentModal
This commit is contained in:
parent
ec82eb2881
commit
2fc1df8793
@ -20,8 +20,6 @@ import { loggerService } from '@logger'
|
||||
import ClaudeIcon from '@renderer/assets/images/models/claude.png'
|
||||
import { useAddAgent } from '@renderer/hooks/agents/useAddAgent'
|
||||
import { useUpdateAgent } from '@renderer/hooks/agents/useUpdateAgent'
|
||||
import { useTimer } from '@renderer/hooks/useTimer'
|
||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
|
||||
import { AddAgentForm, AgentEntity, AgentType, BaseAgentForm, isAgentType, UpdateAgentForm } from '@renderer/types'
|
||||
import { ChangeEvent, FormEvent, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@ -85,7 +83,7 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
||||
const { isOpen, onClose, onOpen } = useDisclosure({ isOpen: _isOpen, onClose: _onClose })
|
||||
const { t } = useTranslation()
|
||||
const loadingRef = useRef(false)
|
||||
const { setTimeoutTimer } = useTimer()
|
||||
// const { setTimeoutTimer } = useTimer()
|
||||
const { addAgent } = useAddAgent()
|
||||
const { updateAgent } = useUpdateAgent()
|
||||
const isEditing = (agent?: AgentEntity) => agent !== undefined
|
||||
@ -245,7 +243,6 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
||||
|
||||
updateAgent(updatePayload)
|
||||
logger.debug('Updated agent', updatePayload)
|
||||
window.toast.success(t('common.update_success'))
|
||||
} else {
|
||||
const newAgent = {
|
||||
type: form.type,
|
||||
@ -257,12 +254,11 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
||||
} satisfies AddAgentForm
|
||||
addAgent(newAgent)
|
||||
logger.debug('Added agent', newAgent)
|
||||
window.toast.success(t('common.add_success'))
|
||||
}
|
||||
|
||||
loadingRef.current = false
|
||||
|
||||
setTimeoutTimer('onCreateAgent', () => EventEmitter.emit(EVENT_NAMES.SHOW_ASSISTANTS), 0)
|
||||
// setTimeoutTimer('onCreateAgent', () => EventEmitter.emit(EVENT_NAMES.SHOW_ASSISTANTS), 0)
|
||||
onClose()
|
||||
},
|
||||
[
|
||||
@ -273,7 +269,6 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
||||
form.instructions,
|
||||
form.accessible_paths,
|
||||
agent,
|
||||
setTimeoutTimer,
|
||||
onClose,
|
||||
t,
|
||||
updateAgent,
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { AddAgentForm } from '@renderer/types'
|
||||
|
||||
export const useAddAgent = () => {
|
||||
// const { t } = useTranslation()
|
||||
return {
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
addAgent: (payload: AddAgentForm) => {
|
||||
window.toast.info('Not implemented')
|
||||
// window.toast.success(t('common.add_success'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ export const useUpdateAgent = () => {
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
updateAgent: (payload: UpdateAgentForm) => {
|
||||
window.toast.info('Not implemented')
|
||||
// window.toast.success(t('common.update_success'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,8 +29,7 @@ export const AgentsTab: FC<AssistantsTabProps> = () => {
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="agents-tab h-full w-full">
|
||||
<span className="mb-2 text-foreground-400 text-xs">{t('common.agent_other')}</span>
|
||||
<div className="agents-tab h-full w-full p-2">
|
||||
{agents.map((agent) => (
|
||||
<AgentItem
|
||||
key={agent.id}
|
||||
|
||||
@ -135,7 +135,6 @@ const Assistants: FC<AssistantsTabProps> = ({
|
||||
|
||||
return (
|
||||
<Container className="assistants-tab" ref={containerRef}>
|
||||
<span className="mb-2 text-foreground-400 text-xs">{t('common.assistant_other')}</span>
|
||||
<DraggableList
|
||||
list={assistants}
|
||||
onUpdate={updateAssistants}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user