forked from open-webui/open-webui
		
	fix: non existent chat page issue
This commit is contained in:
		
							parent
							
								
									b777b6d2aa
								
							
						
					
					
						commit
						0c30a08596
					
				
					 3 changed files with 47 additions and 34 deletions
				
			
		|  | @ -75,7 +75,14 @@ async def get_chat_by_id(id: str, cred=Depends(bearer_scheme)): | ||||||
| 
 | 
 | ||||||
|     if user: |     if user: | ||||||
|         chat = Chats.get_chat_by_id_and_user_id(id, user.id) |         chat = Chats.get_chat_by_id_and_user_id(id, user.id) | ||||||
|  | 
 | ||||||
|  |         if chat: | ||||||
|             return ChatResponse(**{**chat.model_dump(), "chat": json.loads(chat.chat)}) |             return ChatResponse(**{**chat.model_dump(), "chat": json.loads(chat.chat)}) | ||||||
|  |         else: | ||||||
|  |             raise HTTPException( | ||||||
|  |                 status_code=status.HTTP_401_UNAUTHORIZED, | ||||||
|  |                 detail=ERROR_MESSAGES.NOT_FOUND, | ||||||
|  |             ) | ||||||
|     else: |     else: | ||||||
|         raise HTTPException( |         raise HTTPException( | ||||||
|             status_code=status.HTTP_401_UNAUTHORIZED, |             status_code=status.HTTP_401_UNAUTHORIZED, | ||||||
|  |  | ||||||
|  | @ -26,5 +26,6 @@ class ERROR_MESSAGES(str, Enum): | ||||||
|     ACTION_PROHIBITED = ( |     ACTION_PROHIBITED = ( | ||||||
|         "The requested action has been restricted as a security measure." |         "The requested action has been restricted as a security measure." | ||||||
|     ) |     ) | ||||||
|  |     NOT_FOUND = "We could not find what you're looking for :/" | ||||||
|     USER_NOT_FOUND = "We could not find what you're looking for :/" |     USER_NOT_FOUND = "We could not find what you're looking for :/" | ||||||
|     MALICIOUS = "Unusual activities detected, please try again in a few minutes." |     MALICIOUS = "Unusual activities detected, please try again in a few minutes." | ||||||
|  |  | ||||||
|  | @ -71,8 +71,12 @@ | ||||||
| 
 | 
 | ||||||
| 	const loadChat = async () => { | 	const loadChat = async () => { | ||||||
| 		await chatId.set($page.params.id); | 		await chatId.set($page.params.id); | ||||||
| 		chat = await getChatById(localStorage.token, $chatId); | 		chat = await getChatById(localStorage.token, $chatId).catch(async (error) => { | ||||||
|  | 			await goto('/'); | ||||||
|  | 			return null; | ||||||
|  | 		}); | ||||||
| 
 | 
 | ||||||
|  | 		if (chat) { | ||||||
| 			const chatContent = chat.chat; | 			const chatContent = chat.chat; | ||||||
| 
 | 
 | ||||||
| 			if (chatContent) { | 			if (chatContent) { | ||||||
|  | @ -106,6 +110,7 @@ | ||||||
| 			} else { | 			} else { | ||||||
| 				return null; | 				return null; | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	const copyToClipboard = (text) => { | 	const copyToClipboard = (text) => { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek