fix: lint warning
This commit is contained in:
parent
3f285d0676
commit
d1087ec87c
@ -11,29 +11,27 @@ const Scrollbar: FC<Props> = forwardRef<HTMLDivElement, Props>((props, ref) => {
|
||||
const [isScrolling, setIsScrolling] = useState(false)
|
||||
const timeoutRef = useRef<NodeJS.Timeout | null>(null)
|
||||
|
||||
const handleScroll = useCallback(
|
||||
throttle(() => {
|
||||
setIsScrolling(true)
|
||||
const handleScroll = useCallback(() => {
|
||||
setIsScrolling(true)
|
||||
|
||||
if (timeoutRef.current) {
|
||||
clearTimeout(timeoutRef.current)
|
||||
}
|
||||
if (timeoutRef.current) {
|
||||
clearTimeout(timeoutRef.current)
|
||||
}
|
||||
|
||||
timeoutRef.current = setTimeout(() => setIsScrolling(false), 1500) // 增加到 2 秒
|
||||
}, 200),
|
||||
[]
|
||||
)
|
||||
timeoutRef.current = setTimeout(() => setIsScrolling(false), 1500)
|
||||
}, [])
|
||||
|
||||
const throttledHandleScroll = throttle(handleScroll, 200)
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (timeoutRef.current) {
|
||||
clearTimeout(timeoutRef.current)
|
||||
}
|
||||
timeoutRef.current && clearTimeout(timeoutRef.current)
|
||||
throttledHandleScroll.cancel()
|
||||
}
|
||||
}, [])
|
||||
}, [throttledHandleScroll])
|
||||
|
||||
return (
|
||||
<Container {...props} isScrolling={isScrolling} onScroll={handleScroll} ref={ref}>
|
||||
<Container {...props} isScrolling={isScrolling} onScroll={throttledHandleScroll} ref={ref}>
|
||||
{props.children}
|
||||
</Container>
|
||||
)
|
||||
|
||||
@ -88,7 +88,7 @@ const AgentsPage: FC = () => {
|
||||
[t]
|
||||
)
|
||||
|
||||
const getAgentFromSystemAgent = (agent: (typeof systemAgents)[number]) => {
|
||||
const getAgentFromSystemAgent = useCallback((agent: (typeof systemAgents)[number]) => {
|
||||
return {
|
||||
...omit(agent, 'group'),
|
||||
name: agent.name,
|
||||
@ -96,7 +96,7 @@ const AgentsPage: FC = () => {
|
||||
topics: [],
|
||||
type: 'agent'
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const getLocalizedGroupName = useCallback(
|
||||
(group: string) => {
|
||||
@ -121,7 +121,7 @@ const AgentsPage: FC = () => {
|
||||
</Row>
|
||||
)
|
||||
},
|
||||
[onAddAgentConfirm]
|
||||
[getAgentFromSystemAgent, onAddAgentConfirm]
|
||||
)
|
||||
|
||||
const tabItems = useMemo(() => {
|
||||
|
||||
@ -61,6 +61,7 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||
}
|
||||
}
|
||||
updateTokenCount()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [form.getFieldValue('prompt')])
|
||||
|
||||
const onFinish = (values: FieldType) => {
|
||||
|
||||
@ -33,6 +33,7 @@ const HomePage: FC = () => {
|
||||
useEffect(() => {
|
||||
state?.assistant && setActiveAssistant(state?.assistant)
|
||||
state?.topic && setActiveTopic(state?.topic)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [state])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -77,7 +77,6 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
|
||||
const [expended, setExpend] = useState(false)
|
||||
const [estimateTokenCount, setEstimateTokenCount] = useState(0)
|
||||
const [contextCount, setContextCount] = useState({ current: 0, max: 0 })
|
||||
// const generating = useAppSelector((state) => state.runtime.generating)
|
||||
const textareaRef = useRef<TextAreaRef>(null)
|
||||
const [files, setFiles] = useState<FileType[]>(_files)
|
||||
const { t } = useTranslation()
|
||||
@ -110,18 +109,21 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
|
||||
const [mentionFromKeyboard, setMentionFromKeyboard] = useState(false)
|
||||
|
||||
const debouncedEstimate = useCallback(
|
||||
debounce((newText) => {
|
||||
(newText: string) => {
|
||||
if (showInputEstimatedTokens) {
|
||||
const count = estimateTxtTokens(newText) || 0
|
||||
setTokenCount(count)
|
||||
}
|
||||
}, 500),
|
||||
},
|
||||
[showInputEstimatedTokens]
|
||||
)
|
||||
|
||||
const debouncedEstimateWithDelay = debounce(debouncedEstimate, 500)
|
||||
|
||||
useEffect(() => {
|
||||
debouncedEstimate(text)
|
||||
}, [text, debouncedEstimate])
|
||||
debouncedEstimateWithDelay(text)
|
||||
return () => debouncedEstimateWithDelay.cancel()
|
||||
}, [text, debouncedEstimateWithDelay])
|
||||
|
||||
const inputTokenCount = showInputEstimatedTokens ? tokenCount : 0
|
||||
|
||||
@ -438,7 +440,7 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
|
||||
}
|
||||
}
|
||||
},
|
||||
[pasteLongTextAsFile, pasteLongTextThreshold, supportExts, t, text]
|
||||
[model, pasteLongTextAsFile, pasteLongTextThreshold, resizeTextArea, supportExts, t, text]
|
||||
)
|
||||
|
||||
const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
|
||||
@ -548,7 +550,7 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
|
||||
})
|
||||
]
|
||||
return () => unsubscribes.forEach((unsub) => unsub())
|
||||
}, [addNewTopic])
|
||||
}, [addNewTopic, resizeTextArea])
|
||||
|
||||
useEffect(() => {
|
||||
textareaRef.current?.focus()
|
||||
@ -556,6 +558,7 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => resizeTextArea(), 0)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -86,22 +86,19 @@ const MessageMenubar: FC<Props> = (props) => {
|
||||
|
||||
const handleResendUserMessage = useCallback(
|
||||
async (messageUpdate?: Message) => {
|
||||
// messageUpdate 为了处理用户消息更改后的message
|
||||
if (loading) return
|
||||
const groupdMessages = messages.filter((m) => m.askId === message.id)
|
||||
if (!loading) {
|
||||
const groupdMessages = messages.filter((m) => m.askId === message.id)
|
||||
|
||||
// Resend all grouped messages
|
||||
if (!isEmpty(groupdMessages)) {
|
||||
// for (const assistantMessage of groupdMessages) {
|
||||
// const _model = assistantMessage.model || assistantModel
|
||||
await resendMessage(message, assistant)
|
||||
// }
|
||||
return
|
||||
// Resend all grouped messages
|
||||
if (!isEmpty(groupdMessages)) {
|
||||
await resendMessage(message, assistant)
|
||||
return
|
||||
}
|
||||
|
||||
await resendMessage(messageUpdate ?? message, assistant)
|
||||
}
|
||||
|
||||
await resendMessage(messageUpdate ?? message, assistant)
|
||||
},
|
||||
[message, assistantModel, resendMessage, assistant, messages, loading]
|
||||
[message, resendMessage, assistant, messages, loading]
|
||||
)
|
||||
|
||||
const onEdit = useCallback(async () => {
|
||||
|
||||
@ -48,16 +48,8 @@ const Suggestions: FC<Props> = ({ assistant, messages }) => {
|
||||
|
||||
useEffect(() => {
|
||||
suggestionsHandle()
|
||||
// const unsubscribes = [
|
||||
// EventEmitter.on(EVENT_NAMES.RECEIVE_MESSAGE, async (msg: Message) => {
|
||||
|
||||
// ]
|
||||
// return () => {
|
||||
// for (const unsub of unsubscribes) {
|
||||
// unsub()
|
||||
// }
|
||||
// }
|
||||
}, []) // Remove messages dependency
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
setSuggestions(suggestionsMap.get(messages[messages.length - 1]?.id) || [])
|
||||
|
||||
@ -182,6 +182,7 @@ const AssistantModelSettings: FC<Props> = ({ assistant, updateAssistant, updateA
|
||||
|
||||
useEffect(() => {
|
||||
return () => updateAssistantSettings({ customParameters: customParametersRef.current })
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
const formatSliderTooltip = (value?: number) => {
|
||||
|
||||
@ -324,8 +324,11 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
||||
</Space.Compact>
|
||||
{isOpenAIProvider(provider) && (
|
||||
<SettingHelpTextRow style={{ justifyContent: 'space-between' }}>
|
||||
<SettingHelpText style={{ marginLeft: 6, marginRight: "1em", whiteSpace: "break-spaces", wordBreak: "break-all" }}>{hostPreview()}</SettingHelpText>
|
||||
<SettingHelpText style={{ minWidth: "fit-content" }}>{t('settings.provider.api.url.tip')}</SettingHelpText>
|
||||
<SettingHelpText
|
||||
style={{ marginLeft: 6, marginRight: '1em', whiteSpace: 'break-spaces', wordBreak: 'break-all' }}>
|
||||
{hostPreview()}
|
||||
</SettingHelpText>
|
||||
<SettingHelpText style={{ minWidth: 'fit-content' }}>{t('settings.provider.api.url.tip')}</SettingHelpText>
|
||||
</SettingHelpTextRow>
|
||||
)}
|
||||
{isAzureOpenAI && (
|
||||
|
||||
@ -4749,7 +4749,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"commander@npm:^2.8.1":
|
||||
"commander@npm:^2.19.0, commander@npm:^2.8.1":
|
||||
version: 2.20.3
|
||||
resolution: "commander@npm:2.20.3"
|
||||
checksum: 10c0/74c781a5248c2402a0a3e966a0a2bba3c054aad144f5c023364be83265e796b20565aa9feff624132ff629aa64e16999fa40a743c10c12f7c61e96a794b99288
|
||||
@ -9362,6 +9362,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"longest-streak@npm:^2.0.0":
|
||||
version: 2.0.4
|
||||
resolution: "longest-streak@npm:2.0.4"
|
||||
checksum: 10c0/918fb5104cde537757f44431776d6d828bc091a63ca38a3b3e59a08b88498b4421bf5fd9823ef22b4d186f0234d9943087fa96bd6117d26dedcf6008480fd46a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"longest-streak@npm:^3.0.0":
|
||||
version: 3.1.0
|
||||
resolution: "longest-streak@npm:3.1.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user