cleanup search documents action
This commit is contained in:
@@ -48,9 +48,7 @@ function CommandBar() {
|
||||
t("Type a command or search")
|
||||
}…`}
|
||||
/>
|
||||
<CommandBarResults
|
||||
prioritizeSearchResults={ui.commandBarOpenedFromSidebar}
|
||||
/>
|
||||
<CommandBarResults />
|
||||
{ui.commandBarOpenedFromSidebar && (
|
||||
<Hint size="small" type="tertiary">
|
||||
<QuestionMarkIcon size={18} color="currentColor" />
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
import { useMatches, KBarResults } from "kbar";
|
||||
import { orderBy } from "lodash";
|
||||
import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import CommandBarItem from "~/components/CommandBarItem";
|
||||
import { SearchSection } from "~/actions/sections";
|
||||
|
||||
type Props = {
|
||||
prioritizeSearchResults: boolean;
|
||||
};
|
||||
|
||||
export default function CommandBarResults(props: Props) {
|
||||
export default function CommandBarResults() {
|
||||
const { results, rootActionId } = useMatches();
|
||||
|
||||
return (
|
||||
<KBarResults
|
||||
items={orderBy(results, (item) =>
|
||||
// this is an unfortunate hack until kbar supports priority internally
|
||||
typeof item !== "string" &&
|
||||
item.section === SearchSection &&
|
||||
props.prioritizeSearchResults
|
||||
? -1
|
||||
: 1
|
||||
)}
|
||||
items={results}
|
||||
maxHeight={400}
|
||||
onRender={({ item, active }) =>
|
||||
typeof item === "string" ? (
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { useKBar } from "kbar";
|
||||
import * as React from "react";
|
||||
import {
|
||||
navigateToRecentSearchQuery,
|
||||
navigateToSearchQuery,
|
||||
} from "~/actions/definitions/navigation";
|
||||
import { searchDocumentsForQuery } from "~/actions/definitions/documents";
|
||||
import { navigateToRecentSearchQuery } from "~/actions/definitions/navigation";
|
||||
|
||||
import useCommandBarActions from "~/hooks/useCommandBarActions";
|
||||
import useStores from "~/hooks/useStores";
|
||||
|
||||
@@ -18,7 +17,9 @@ export default function SearchActions() {
|
||||
searchQuery: state.searchQuery,
|
||||
}));
|
||||
|
||||
useCommandBarActions(searchQuery ? [navigateToSearchQuery(searchQuery)] : []);
|
||||
useCommandBarActions(
|
||||
searchQuery ? [searchDocumentsForQuery(searchQuery)] : []
|
||||
);
|
||||
|
||||
useCommandBarActions(searches.recent.map(navigateToRecentSearchQuery));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user