This commit is contained in:
Manav Rathi
2024-09-11 20:58:23 +05:30
parent e0db188195
commit c2ea68c39c
3 changed files with 4 additions and 25 deletions

View File

@@ -1,6 +1,5 @@
import { assertionFailed } from "@/base/assert";
import { useIsMobileWidth } from "@/base/hooks";
import type { Collection } from "@/media/collection";
import { FileType } from "@/media/file-type";
import {
isMLSupported,
@@ -22,7 +21,6 @@ import {
} from "@/new/photos/services/search/types";
import { labelForSuggestionType } from "@/new/photos/services/search/ui";
import type { LocationTag } from "@/new/photos/services/user-entity";
import { EnteFile } from "@/new/photos/types/file";
import {
FreeFlowText,
SpaceBetweenFlex,
@@ -76,8 +74,6 @@ interface SearchBarProps {
/** Enter or exit search mode. */
setIsInSearchMode: (v: boolean) => void;
updateSearch: UpdateSearch;
collections: Collection[];
files: EnteFile[];
}
export type UpdateSearch = (
@@ -140,16 +136,12 @@ interface SearchInputProps {
isOpen: boolean;
setIsOpen: (value: boolean) => void;
updateSearch: UpdateSearch;
files: EnteFile[];
collections: Collection[];
}
const SearchInput: React.FC<SearchInputProps> = ({
isOpen,
setIsOpen,
updateSearch,
files,
collections,
}) => {
const appContext = useContext(AppContext);
@@ -199,8 +191,8 @@ const SearchInput: React.FC<SearchInputProps> = ({
};
const getOptions = useCallback(
pDebounce(getAutoCompleteSuggestions(files, collections), 250),
[files, collections],
pDebounce(getAutoCompleteSuggestions(), 250),
[],
);
const search = (selectedOption: SearchOption) => {

View File

@@ -1099,8 +1099,6 @@ export default function Gallery() {
isInSearchMode={isInSearchMode}
setIsInSearchMode={setIsInSearchMode}
updateSearch={updateSearch}
collections={collections}
files={files}
/>
)}
</NavbarBase>
@@ -1279,8 +1277,6 @@ interface NormalNavbarContentsProps {
isInSearchMode: boolean;
setIsInSearchMode: (v: boolean) => void;
updateSearch: UpdateSearch;
collections: Collection[];
files: EnteFile[];
}
const NormalNavbarContents: React.FC<NormalNavbarContentsProps> = ({
@@ -1289,8 +1285,6 @@ const NormalNavbarContents: React.FC<NormalNavbarContentsProps> = ({
isInSearchMode,
setIsInSearchMode,
updateSearch,
collections,
files,
}) => (
<>
{!isInSearchMode && <SidebarButton onClick={openSidebar} />}
@@ -1298,8 +1292,6 @@ const NormalNavbarContents: React.FC<NormalNavbarContentsProps> = ({
isInSearchMode={isInSearchMode}
setIsInSearchMode={setIsInSearchMode}
updateSearch={updateSearch}
collections={collections}
files={files}
/>
{!isInSearchMode && <UploadButton onClick={openUploader} />}
</>

View File

@@ -2,11 +2,9 @@ import { isDesktop } from "@/base/app";
import log from "@/base/log";
import { masterKeyFromSession } from "@/base/session-store";
import { ComlinkWorker } from "@/base/worker/comlink-worker";
import type { Collection } from "@/media/collection";
import { FileType } from "@/media/file-type";
import type { LocationTag } from "@/new/photos/services/user-entity";
import i18n, { t } from "i18next";
import type { EnteFile } from "../../types/file";
import { clipMatches, isMLEnabled } from "../ml";
import type {
City,
@@ -166,12 +164,9 @@ const labelledFileTypes = (): LabelledFileType[] => [
// Suggestions shown in the search dropdown when the user has typed something.
export const getAutoCompleteSuggestions =
(files: EnteFile[], collections: Collection[]) =>
() =>
async (searchPhrase: string): Promise<SearchOption[]> => {
log.debug(() => [
"getAutoCompleteSuggestions",
{ searchPhrase, files, collections },
]);
log.debug(() => ["getAutoCompleteSuggestions"]);
try {
const suggestions: Suggestion[] =
await suggestionsForString(searchPhrase);