Refactor quicklaunch fallback to search widget suggestions setting

pull/2775/head
shamoon 4 months ago
parent 2729a3b03e
commit ef25756534

@ -1,7 +1,6 @@
import { useTranslation } from "react-i18next";
import { useEffect, useState, useRef, useCallback, useContext } from "react";
import classNames from "classnames";
import useSWR from "swr";
import ResolvedIcon from "./resolvedicon";
@ -17,18 +16,11 @@ export default function QuickLaunch({
}) {
const { t } = useTranslation();
const { data: widgets } = useSWR("/api/widgets");
const searchWidget = Object.values(widgets).find((w) => w.type === "search");
const { settings } = useContext(SettingsContext);
const { searchDescriptions, hideVisitURL } = settings?.quicklaunch
? settings.quicklaunch
: {
searchDescriptions: false,
hideVisitURL: false,
};
const showSearchSuggestions =
settings?.quicklaunch?.showSearchSuggestions ?? searchWidget.options.showSearchSuggestions ?? false;
const { searchDescriptions = false, hideVisitURL = false } = settings?.quicklaunch ?? {};
const showSearchSuggestions = !!(
settings?.quicklaunch?.showSearchSuggestions ?? searchProvider.showSearchSuggestions
);
const searchField = useRef();

@ -211,10 +211,7 @@ function Home({ initialSettings }) {
// if search provider is a list, try to retrieve from localstorage, fall back to the first
searchProvider = getStoredProvider() ?? searchProviders[searchWidget.options.provider[0]];
} else if (searchWidget.options?.provider === "custom") {
searchProvider = {
url: searchWidget.options.url,
suggestionUrl: searchWidget.options.suggestionUrl,
};
searchProvider = searchWidget.options;
} else {
searchProvider = searchProviders[searchWidget.options?.provider];
}

Loading…
Cancel
Save