Add search mode settings and textarea focus on form submission

This commit is contained in:
n4ze3m
2024-03-04 00:32:01 +05:30
parent a87c56061c
commit 1b689c91c0
8 changed files with 88 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ import { PageAssitDatabase } from "~libs/db"
import { Select } from "antd"
import { SUPPORTED_LANGUAGES } from "~utils/supporetd-languages"
import { MoonIcon, SunIcon } from "lucide-react"
import { SearchModeSettings } from "./search-mode"
export const SettingOther = () => {
const { clearChat, speechToTextLanguage, setSpeechToTextLanguage } =
@@ -82,6 +83,7 @@ export const SettingOther = () => {
Delete
</button>
</div>
<SearchModeSettings />
</dl>
)
}

View File

@@ -0,0 +1,37 @@
import { useQuery, useQueryClient } from "@tanstack/react-query"
import { Skeleton, Switch } from "antd"
import {
getIsSimpleInternetSearch,
setIsSimpleInternetSearch
} from "~services/ollama"
export const SearchModeSettings = () => {
const { data, status } = useQuery({
queryKey: ["fetchIsSimpleInternetSearch"],
queryFn: () => getIsSimpleInternetSearch()
})
const queryClient = useQueryClient()
if (status === "pending" || status === "error") {
return <Skeleton active />
}
return (
<div className="flex flex-row justify-between">
<span className="text-gray-500 dark:text-gray-400 text-lg">
Perform Simple Internet Search
</span>
<Switch
checked={data}
onChange={(checked) => {
setIsSimpleInternetSearch(checked)
queryClient.invalidateQueries({
queryKey: ["fetchIsSimpleInternetSearch"]
})
}}
/>
</div>
)
}