Fix: Update temporary chat history
This commit addresses an issue where temporary chat history was not being updated correctly when using voice input. The `setHistoryId` function is now called within the `saveMessageOnError` function to ensure that the history ID is set correctly when a message is saved.
This commit is contained in:
		
							parent
							
								
									55f3838b6d
								
							
						
					
					
						commit
						0f75de02cb
					
				| @ -366,6 +366,8 @@ export const useMessageOption = () => { | |||||||
|   const saveMessageOnSuccess = async (e: any) => { |   const saveMessageOnSuccess = async (e: any) => { | ||||||
|     if (!temporaryChat) { |     if (!temporaryChat) { | ||||||
|       return await saveSuccess(e) |       return await saveSuccess(e) | ||||||
|  |     } else { | ||||||
|  |       setHistoryId("temp") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return true |     return true | ||||||
| @ -374,6 +376,21 @@ export const useMessageOption = () => { | |||||||
|   const saveMessageOnError = async (e: any) => { |   const saveMessageOnError = async (e: any) => { | ||||||
|     if (!temporaryChat) { |     if (!temporaryChat) { | ||||||
|       return await saveError(e) |       return await saveError(e) | ||||||
|  |     } else { | ||||||
|  |       setHistory([ | ||||||
|  |         ...history, | ||||||
|  |         { | ||||||
|  |           role: "user", | ||||||
|  |           content: e.userMessage, | ||||||
|  |           image: e.image | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |           role: "assistant", | ||||||
|  |           content: e.botMessage | ||||||
|  |         } | ||||||
|  |       ]) | ||||||
|  | 
 | ||||||
|  |       setHistoryId("temp") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return true |     return true | ||||||
| @ -1069,6 +1086,6 @@ export const useMessageOption = () => { | |||||||
|     setSelectedKnowledge, |     setSelectedKnowledge, | ||||||
|     ttsEnabled, |     ttsEnabled, | ||||||
|     temporaryChat, |     temporaryChat, | ||||||
|     setTemporaryChat, |     setTemporaryChat | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user