Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: separate Internet search settings for quicklaunch #3541

Merged
merged 11 commits into from
Jun 1, 2024
Prev Previous commit
Next Next commit
Handle case when custom provider but no url given
  • Loading branch information
shamoon committed Jun 1, 2024
commit a54f618dfdd073a5ec345ab5a814785934466829
10 changes: 4 additions & 6 deletions src/components/quicklaunch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
const { data: widgets } = useSWR("/api/widgets");

function getSearchProvider() {
if (settings?.quicklaunch?.hideInternetSearch) return null;

const searchWidget = Object.values(widgets).find((w) => w.type === "search");
let searchProvider = null;
let searchProvider;

if (settings?.quicklaunch?.provider === "custom") {
if (settings?.quicklaunch?.provider === "custom" && settings?.quicklaunch?.url?.length > 0) {
searchProvider = settings.quicklaunch;
} else if (settings?.quicklaunch?.provider) {
} else if (settings?.quicklaunch?.provider !== "custom") {
searchProvider = searchProviders[settings.quicklaunch.provider];
} else if (searchWidget) {
// If there is no search provider in quick launch settings, try to get it from the search widget
Expand All @@ -57,7 +55,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
return searchProvider;
}

const searchProvider = getSearchProvider();
const searchProvider = settings?.quicklaunch?.hideInternetSearch === false ? null : getSearchProvider();

function openCurrentItem(newWindow) {
const result = results[currentItemIndex];
Expand Down