1- import { useEffect } from "react" ;
1+ import { useEffect , useState } from "react" ;
22import { useTranslation } from "react-i18next" ;
33import {
44 AppWindowMac ,
5+ ArrowUpWideNarrow ,
56 MessageSquareMore ,
67 Search ,
78 ShieldCheck ,
@@ -18,6 +19,7 @@ import SettingsInput from "@/components//Settings/SettingsInput";
1819import platformAdapter from "@/utils/platformAdapter" ;
1920import UpdateSettings from "./components/UpdateSettings" ;
2021import SettingsToggle from "../SettingsToggle" ;
22+ import { isNil } from "lodash-es" ;
2123
2224const Advanced = ( ) => {
2325 const { t } = useTranslation ( ) ;
@@ -57,13 +59,22 @@ const Advanced = () => {
5759 const setAllowSelfSignature = useConnectStore ( ( state ) => {
5860 return state . setAllowSelfSignature ;
5961 } ) ;
62+ const { searchDelay, setSearchDelay } = useConnectStore ( ) ;
63+
64+ const [ localSearchResultWeight , setLocalSearchResultWeight ] = useState ( 1 ) ;
6065
6166 useMount ( async ( ) => {
6267 const allowSelfSignature = await platformAdapter . invokeBackend < boolean > (
6368 "get_allow_self_signature"
6469 ) ;
6570
6671 setAllowSelfSignature ( allowSelfSignature ) ;
72+
73+ const weight = await platformAdapter . invokeBackend < number > (
74+ "get_local_query_source_weight"
75+ ) ;
76+
77+ setLocalSearchResultWeight ( weight ) ;
6778 } ) ;
6879
6980 useEffect ( ( ) => {
@@ -174,16 +185,20 @@ const Advanced = () => {
174185
175186 < Shortcuts />
176187
188+ < Appearance />
189+
190+ < UpdateSettings />
191+
177192 < h2 className = "text-lg font-semibold text-gray-900 dark:text-white mb-4" >
178- { t ( "settings.advanced.connect .title" ) }
193+ { t ( "settings.advanced.other .title" ) }
179194 </ h2 >
180195
181196 < div className = "space-y-6" >
182197 < SettingsItem
183198 icon = { Unplug }
184- title = { t ( "settings.advanced.connect .connectionTimeout.title" ) }
199+ title = { t ( "settings.advanced.other .connectionTimeout.title" ) }
185200 description = { t (
186- "settings.advanced.connect .connectionTimeout.description"
201+ "settings.advanced.other .connectionTimeout.description"
187202 ) }
188203 >
189204 < SettingsInput
@@ -198,8 +213,8 @@ const Advanced = () => {
198213
199214 < SettingsItem
200215 icon = { Unplug }
201- title = { t ( "settings.advanced.connect .queryTimeout.title" ) }
202- description = { t ( "settings.advanced.connect .queryTimeout.description" ) }
216+ title = { t ( "settings.advanced.other .queryTimeout.title" ) }
217+ description = { t ( "settings.advanced.other .queryTimeout.description" ) }
203218 >
204219 < SettingsInput
205220 type = "number"
@@ -211,15 +226,30 @@ const Advanced = () => {
211226 />
212227 </ SettingsItem >
213228
229+ < SettingsItem
230+ icon = { Unplug }
231+ title = { t ( "settings.advanced.other.searchDelay.title" ) }
232+ description = { t ( "settings.advanced.other.searchDelay.description" ) }
233+ >
234+ < SettingsInput
235+ type = "number"
236+ min = { 0 }
237+ value = { searchDelay }
238+ onChange = { ( value ) => {
239+ setSearchDelay ( isNil ( value ) ? 0 : Number ( value ) ) ;
240+ } }
241+ />
242+ </ SettingsItem >
243+
214244 < SettingsItem
215245 icon = { ShieldCheck }
216- title = { t ( "settings.advanced.connect .allowSelfSignature.title" ) }
246+ title = { t ( "settings.advanced.other .allowSelfSignature.title" ) }
217247 description = { t (
218- "settings.advanced.connect .allowSelfSignature.description"
248+ "settings.advanced.other .allowSelfSignature.description"
219249 ) }
220250 >
221251 < SettingsToggle
222- label = { t ( "settings.advanced.connect .allowSelfSignature.title" ) }
252+ label = { t ( "settings.advanced.other .allowSelfSignature.title" ) }
223253 checked = { allowSelfSignature }
224254 onChange = { ( value ) => {
225255 setAllowSelfSignature ( value ) ;
@@ -230,11 +260,43 @@ const Advanced = () => {
230260 } }
231261 />
232262 </ SettingsItem >
233- </ div >
234263
235- < Appearance />
264+ < SettingsItem
265+ icon = { ArrowUpWideNarrow }
266+ title = { t ( "settings.advanced.other.localSearchResultWeight.title" ) }
267+ description = { t (
268+ "settings.advanced.other.localSearchResultWeight.description"
269+ ) }
270+ >
271+ < select
272+ value = { localSearchResultWeight }
273+ onChange = { ( event ) => {
274+ const weight = Number ( event . target . value ) ;
236275
237- < UpdateSettings />
276+ setLocalSearchResultWeight ( weight ) ;
277+
278+ platformAdapter . invokeBackend ( "set_local_query_source_weight" , {
279+ value : weight ,
280+ } ) ;
281+ } }
282+ className = "px-3 py-1.5 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
283+ >
284+ < option value = "0.5" >
285+ { t ( "settings.advanced.other.localSearchResultWeight.options.low" ) }
286+ </ option >
287+ < option value = "1" >
288+ { t (
289+ "settings.advanced.other.localSearchResultWeight.options.medium"
290+ ) }
291+ </ option >
292+ < option value = "2" >
293+ { t (
294+ "settings.advanced.other.localSearchResultWeight.options.high"
295+ ) }
296+ </ option >
297+ </ select >
298+ </ SettingsItem >
299+ </ div >
238300 </ div >
239301 ) ;
240302} ;
0 commit comments