mirror of https://github.com/langgenius/dify.git
refactor: use const instead of let reassignment in state updater
Replace mutable let variable with const declarations for the previous app conversations lookup, making the functional state update logic more declarative. Signed-off-by: majiayu000 <1835304752@qq.com>
This commit is contained in:
parent
91446d2556
commit
7f517a944f
|
|
@ -181,13 +181,14 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
|
|||
const handleConversationIdInfoChange = useCallback((changeConversationId: string) => {
|
||||
if (appId) {
|
||||
setConversationIdInfo((prev) => {
|
||||
let prevValue = prev?.[appId || '']
|
||||
if (typeof prevValue === 'string')
|
||||
prevValue = {}
|
||||
const prevAppConversations = prev?.[appId || '']
|
||||
const base = typeof prevAppConversations === 'object' && prevAppConversations
|
||||
? prevAppConversations
|
||||
: {}
|
||||
return {
|
||||
...prev,
|
||||
[appId || '']: {
|
||||
...prevValue,
|
||||
...base,
|
||||
[userId || 'DEFAULT']: changeConversationId,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,13 +147,14 @@ export const useEmbeddedChatbot = (appSourceType: AppSourceType, tryAppId?: stri
|
|||
const handleConversationIdInfoChange = useCallback((changeConversationId: string) => {
|
||||
if (appId) {
|
||||
setConversationIdInfo((prev) => {
|
||||
let prevValue = prev?.[appId || '']
|
||||
if (typeof prevValue === 'string')
|
||||
prevValue = {}
|
||||
const prevAppConversations = prev?.[appId || '']
|
||||
const base = typeof prevAppConversations === 'object' && prevAppConversations
|
||||
? prevAppConversations
|
||||
: {}
|
||||
return {
|
||||
...prev,
|
||||
[appId || '']: {
|
||||
...prevValue,
|
||||
...base,
|
||||
[userId || 'DEFAULT']: changeConversationId,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue