Ran pre-commit hook
This commit is contained in:
parent
262d9f7d44
commit
ac0ca8c14f
@ -89,7 +89,7 @@ export default function QuickLaunch({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [searchSuggestions, setSearchSuggestions] = useState([])
|
const [searchSuggestions, setSearchSuggestions] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (searchString.length === 0) setResults([]);
|
if (searchString.length === 0) setResults([]);
|
||||||
else {
|
else {
|
||||||
@ -116,31 +116,35 @@ export default function QuickLaunch({
|
|||||||
|
|
||||||
if (!hideSearchSuggestions && searchProvider.suggestionUrl) {
|
if (!hideSearchSuggestions && searchProvider.suggestionUrl) {
|
||||||
if (searchString.trim() !== searchSuggestions[0]) {
|
if (searchString.trim() !== searchSuggestions[0]) {
|
||||||
fetch(`/api/searchSuggestion?query=${encodeURIComponent(searchString)}&providerName=${searchProvider.name}`).then(async (searchSuggestionResult) => {
|
fetch(`/api/searchSuggestion?query=${encodeURIComponent(searchString)}&providerName=${searchProvider.name}`)
|
||||||
const newSearchSuggestions = await searchSuggestionResult.json();
|
.then(async (searchSuggestionResult) => {
|
||||||
|
const newSearchSuggestions = await searchSuggestionResult.json();
|
||||||
|
|
||||||
// Check if there is a search suggestion
|
// Check if there is a search suggestion
|
||||||
if (newSearchSuggestions) {
|
if (newSearchSuggestions) {
|
||||||
// Restrict the searchSuggestion to 4 entries
|
// Restrict the searchSuggestion to 4 entries
|
||||||
if (newSearchSuggestions[1].length - 4 > 0) {
|
if (newSearchSuggestions[1].length - 4 > 0) {
|
||||||
newSearchSuggestions[1].splice(-(newSearchSuggestions[1].length-4));
|
newSearchSuggestions[1].splice(-(newSearchSuggestions[1].length - 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the new search suggestions in their state.
|
||||||
|
setSearchSuggestions(newSearchSuggestions);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
// Save the new search suggestions in their state.
|
.catch(() => {
|
||||||
setSearchSuggestions(newSearchSuggestions);
|
// If there is an error, just ignore it. There just will be no search suggestions.
|
||||||
}
|
});
|
||||||
}).catch(() => {
|
|
||||||
// If there is an error, just ignore it. There just will be no search suggestions.
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show search suggestions from their state. This will show the "old" suggestions until they are updated.
|
// Show search suggestions from their state. This will show the "old" suggestions until they are updated.
|
||||||
if (searchSuggestions[1]) {
|
if (searchSuggestions[1]) {
|
||||||
newResults = newResults.concat(searchSuggestions[1].map((suggestion)=>({
|
newResults = newResults.concat(
|
||||||
href: searchProvider.url + encodeURIComponent(suggestion),
|
searchSuggestions[1].map((suggestion) => ({
|
||||||
name: suggestion,
|
href: searchProvider.url + encodeURIComponent(suggestion),
|
||||||
type: "search",
|
name: suggestion,
|
||||||
})));
|
type: "search",
|
||||||
|
})),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,7 +163,17 @@ export default function QuickLaunch({
|
|||||||
setCurrentItemIndex(0);
|
setCurrentItemIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [searchString, servicesAndBookmarks, searchDescriptions, hideVisitURL, hideSearchSuggestions, searchSuggestions, searchProvider, url, t]);
|
}, [
|
||||||
|
searchString,
|
||||||
|
servicesAndBookmarks,
|
||||||
|
searchDescriptions,
|
||||||
|
hideVisitURL,
|
||||||
|
hideSearchSuggestions,
|
||||||
|
searchSuggestions,
|
||||||
|
searchProvider,
|
||||||
|
url,
|
||||||
|
t,
|
||||||
|
]);
|
||||||
|
|
||||||
const [hidden, setHidden] = useState(true);
|
const [hidden, setHidden] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { searchProviders } from "components/widgets/search/search";
|
import { searchProviders } from "components/widgets/search/search";
|
||||||
import cachedFetch from "utils/proxy/cached-fetch";
|
import cachedFetch from "utils/proxy/cached-fetch";
|
||||||
import { widgetsFromConfig } from "utils/config/widget-helpers"
|
import { widgetsFromConfig } from "utils/config/widget-helpers";
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
const { query, providerName } = req.query;
|
const { query, providerName } = req.query;
|
||||||
|
|||||||
@ -211,10 +211,13 @@ function Home({ initialSettings }) {
|
|||||||
// 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 = {...searchProviders.custom, ...{
|
searchProvider = {
|
||||||
url: searchWidget.options.url,
|
...searchProviders.custom,
|
||||||
suggestionUrl: searchWidget.options.suggestionUrl,
|
...{
|
||||||
}};
|
url: searchWidget.options.url,
|
||||||
|
suggestionUrl: searchWidget.options.suggestionUrl,
|
||||||
|
},
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
searchProvider = searchProviders[searchWidget.options?.provider];
|
searchProvider = searchProviders[searchWidget.options?.provider];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user