No reason to be a separate method
This commit is contained in:
parent
a54f618dfd
commit
2df798834b
@ -22,40 +22,34 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
const [searchSuggestions, setSearchSuggestions] = useState([]);
|
const [searchSuggestions, setSearchSuggestions] = useState([]);
|
||||||
|
|
||||||
const { data: widgets } = useSWR("/api/widgets");
|
const { data: widgets } = useSWR("/api/widgets");
|
||||||
|
const searchWidget = Object.values(widgets).find((w) => w.type === "search");
|
||||||
|
|
||||||
function getSearchProvider() {
|
let searchProvider;
|
||||||
const searchWidget = Object.values(widgets).find((w) => w.type === "search");
|
|
||||||
let searchProvider;
|
|
||||||
|
|
||||||
if (settings?.quicklaunch?.provider === "custom" && settings?.quicklaunch?.url?.length > 0) {
|
if (settings?.quicklaunch?.provider === "custom" && settings?.quicklaunch?.url?.length > 0) {
|
||||||
searchProvider = settings.quicklaunch;
|
searchProvider = settings.quicklaunch;
|
||||||
} else if (settings?.quicklaunch?.provider !== "custom") {
|
} else if (settings?.quicklaunch?.provider !== "custom") {
|
||||||
searchProvider = searchProviders[settings.quicklaunch.provider];
|
searchProvider = searchProviders[settings.quicklaunch.provider];
|
||||||
} else if (searchWidget) {
|
} else if (searchWidget) {
|
||||||
// If there is no search provider in quick launch settings, try to get it from the search widget
|
// If there is no search provider in quick launch settings, try to get it from the search widget
|
||||||
if (Array.isArray(searchWidget.options?.provider)) {
|
if (Array.isArray(searchWidget.options?.provider)) {
|
||||||
// If search provider is a list, try to retrieve from localstorage, fall back to the first
|
// If search provider is a list, try to retrieve from localstorage, fall back to the first
|
||||||
searchProvider = getStoredProvider() ?? searchProviders[searchWidget.options.provider[0]];
|
searchProvider = getStoredProvider() ?? searchProviders[searchWidget.options.provider[0]];
|
||||||
} else if (searchWidget.options?.provider === "custom") {
|
} else if (searchWidget.options?.provider === "custom") {
|
||||||
searchProvider = searchWidget.options;
|
searchProvider = searchWidget.options;
|
||||||
} else {
|
} else {
|
||||||
searchProvider = searchProviders[searchWidget.options?.provider];
|
searchProvider = searchProviders[searchWidget.options?.provider];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no search provider in quick launch settings try to get the value from search widget,
|
|
||||||
// if it's not specified there either then set the value to false
|
|
||||||
if (searchProvider)
|
|
||||||
searchProvider.showSearchSuggestions = !!(
|
|
||||||
settings?.quicklaunch?.showSearchSuggestions ??
|
|
||||||
searchWidget?.options?.showSearchSuggestions ??
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
return searchProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchProvider = settings?.quicklaunch?.hideInternetSearch === false ? null : getSearchProvider();
|
// If there is no search provider in quick launch settings try to get the value from search widget,
|
||||||
|
// if it's not specified there either then set the value to false
|
||||||
|
if (searchProvider)
|
||||||
|
searchProvider.showSearchSuggestions = !!(
|
||||||
|
settings?.quicklaunch?.showSearchSuggestions ??
|
||||||
|
searchWidget?.options?.showSearchSuggestions ??
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
function openCurrentItem(newWindow) {
|
function openCurrentItem(newWindow) {
|
||||||
const result = results[currentItemIndex];
|
const result = results[currentItemIndex];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user