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