mirror of
				https://github.com/ItzCrazyKns/Perplexica.git
				synced 2025-10-30 19:08:15 +00:00 
			
		
		
		
	feat(config): add getAutoMediaSearch, update uses
				
					
				
			This commit is contained in:
		| @@ -6,11 +6,8 @@ const getClientConfig = (key: string, defaultVal?: any) => { | ||||
|  | ||||
| export const getTheme = () => getClientConfig('theme', 'dark'); | ||||
|  | ||||
| export const getAutoImageSearch = () => | ||||
|   Boolean(getClientConfig('autoImageSearch', 'true')); | ||||
|  | ||||
| export const getAutoVideoSearch = () => | ||||
|   Boolean(getClientConfig('autoVideoSearch', 'true')); | ||||
| export const getAutoMediaSearch = () => | ||||
|   getClientConfig('autoMediaSearch', 'true') === 'true'; | ||||
|  | ||||
| export const getSystemInstructions = () => | ||||
|   getClientConfig('systemInstructions', ''); | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import { useParams, useSearchParams } from 'next/navigation'; | ||||
| import { toast } from 'sonner'; | ||||
| import { getSuggestions } from '../actions'; | ||||
| import { MinimalProvider } from '../models/types'; | ||||
| import { getAutoMediaSearch } from '../config/clientRegistry'; | ||||
|  | ||||
| export type Section = { | ||||
|   userMessage: UserMessage; | ||||
| @@ -94,17 +95,6 @@ const checkConfig = async ( | ||||
|       'embeddingModelProviderId', | ||||
|     ); | ||||
|  | ||||
|     const autoImageSearch = localStorage.getItem('autoImageSearch'); | ||||
|     const autoVideoSearch = localStorage.getItem('autoVideoSearch'); | ||||
|  | ||||
|     if (!autoImageSearch) { | ||||
|       localStorage.setItem('autoImageSearch', 'true'); | ||||
|     } | ||||
|  | ||||
|     if (!autoVideoSearch) { | ||||
|       localStorage.setItem('autoVideoSearch', 'false'); | ||||
|     } | ||||
|  | ||||
|     const res = await fetch(`/api/providers`, { | ||||
|       headers: { | ||||
|         'Content-Type': 'application/json', | ||||
| @@ -624,16 +614,13 @@ export const ChatProvider = ({ children }: { children: React.ReactNode }) => { | ||||
|  | ||||
|         const lastMsg = messagesRef.current[messagesRef.current.length - 1]; | ||||
|  | ||||
|         const autoImageSearch = localStorage.getItem('autoImageSearch'); | ||||
|         const autoVideoSearch = localStorage.getItem('autoVideoSearch'); | ||||
|         const autoMediaSearch = getAutoMediaSearch(); | ||||
|  | ||||
|         if (autoImageSearch === 'true') { | ||||
|         if (autoMediaSearch) { | ||||
|           document | ||||
|             .getElementById(`search-images-${lastMsg.messageId}`) | ||||
|             ?.click(); | ||||
|         } | ||||
|  | ||||
|         if (autoVideoSearch === 'true') { | ||||
|           document | ||||
|             .getElementById(`search-videos-${lastMsg.messageId}`) | ||||
|             ?.click(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user