Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Namespace

Manav Rathi31459d9339c5
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index fafaedbb87..b1703b6728 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -17,7 +17,7 @@ import {
import { wipHasSwitchedOnceCmpAndSet } from "@/new/photos/services/ml";
import {
filterSearchableFiles,
- setSearchableData,
+ setSearchableCollectionsAndFiles,
} from "@/new/photos/services/search";
import type { SearchOption } from "@/new/photos/services/search/types";
import { EnteFile } from "@/new/photos/types/file";
@@ -411,7 +411,7 @@ export default function Gallery() {
useEffect(
() =>
- setSearchableData({
+ setSearchableCollectionsAndFiles({
collections: collections ?? [],
files: getUniqueFiles(files ?? []),
}),
diff --git a/web/packages/new/photos/services/search/index.ts b/web/packages/new/photos/services/search/index.ts
index 21322c6648..927e9ed8f0 100644
--- a/web/packages/new/photos/services/search/index.ts
+++ b/web/packages/new/photos/services/search/index.ts
@@ -8,7 +8,7 @@ import type {
LabelledFileType,
LabelledSearchDateComponents,
LocalizedSearchData,
- SearchableData,
+ SearchableCollectionsAndFiles,
SearchSuggestion,
} from "./types";
import type { SearchWorker } from "./worker";
@@ -53,8 +53,9 @@ export const triggerSearchDataSync = () =>
/**
* Set the collections and files over which we should search.
*/
-export const setSearchableData = (data: SearchableData) =>
- void worker().then((w) => w.setSearchableData(data));
+export const setSearchableCollectionsAndFiles = (
+ data: SearchableCollectionsAndFiles,
+) => void worker().then((w) => w.setSearchableCollectionsAndFiles(data));
/**
* Convert a search string into (annotated) suggestions that can be shown in the
@@ -113,7 +114,7 @@ const suggestionsToOptions = (suggestions: SearchSuggestion[]) =>
/**
* Return the list of {@link EnteFile}s (from amongst the previously set
- * {@link SearchableData}) that match the given search {@link suggestion}.
+ * {@link SearchableCollectionsAndFiles}) that match the given search {@link suggestion}.
*/
export const filterSearchableFiles = async (suggestion: SearchSuggestion) =>
worker().then((w) => w.filterSearchableFiles(suggestion));
diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.ts
index c22e462282..3a621a39a0 100644
--- a/web/packages/new/photos/services/search/types.ts
+++ b/web/packages/new/photos/services/search/types.ts
@@ -45,9 +45,9 @@ export interface SearchOption {
}
/**
- * The base data over which we should search.
+ * The collections and files which we should search.
*/
-export interface SearchableData {
+export interface SearchableCollectionsAndFiles {
collections: Collection[];
files: EnteFile[];
}
diff --git a/web/packages/new/photos/services/search/worker.ts b/web/packages/new/photos/services/search/worker.ts
index 24f351e058..446cd30456 100644
--- a/web/packages/new/photos/services/search/worker.ts
+++ b/web/packages/new/photos/services/search/worker.ts
@@ -21,7 +21,7 @@ import type {
LabelledSearchDateComponents,
LocalizedSearchData,
Searchable,
- SearchableData,
+ SearchableCollectionsAndFiles,
SearchDateComponents,
SearchSuggestion,
} from "./types";
@@ -31,7 +31,10 @@ import type {
* remains responsive.
*/
export class SearchWorker {
- private searchableData: SearchableData = { collections: [], files: [] };
+ private searchableCollectionsAndFiles: SearchableCollectionsAndFiles = {
+ collections: [],
+ files: [],
+ };
private locationTags: Searchable<LocationTag>[] = [];
private cities: Searchable<City>[] = [];
@@ -61,10 +64,10 @@ export class SearchWorker {
}
/**
- * Set the data that we should search across.
+ * Set the collections and files that we should search across.
*/
- setSearchableData(data: SearchableData) {
- this.searchableData = data;
+ setSearchableCollectionsAndFiles(data: SearchableCollectionsAndFiles) {
+ this.searchableCollectionsAndFiles = data;
}
/**
@@ -78,7 +81,7 @@ export class SearchWorker {
return suggestionsForString(
s,
searchString,
- this.searchableData,
+ this.searchableCollectionsAndFiles,
localizedSearchData,
this.locationTags,
this.cities,
@@ -89,14 +92,17 @@ export class SearchWorker {
* Return {@link EnteFile}s that satisfy the given {@link suggestion}.
*/
filterSearchableFiles(suggestion: SearchSuggestion) {
- return filterSearchableFiles(this.searchableData.files, suggestion);
+ return filterSearchableFiles(
+ this.searchableCollectionsAndFiles.files,
+ suggestion,
+ );
}
/**
* Batched variant of {@link filterSearchableFiles}.
*/
filterSearchableFilesMulti(suggestions: SearchSuggestion[]) {
- const files = this.searchableData.files;
+ const files = this.searchableCollectionsAndFiles.files;
return suggestions
.map((sg) => [filterSearchableFiles(files, sg), sg] as const)
.filter(([files]) => files.length);
@@ -112,7 +118,7 @@ expose(SearchWorker);
const suggestionsForString = (
s: string,
searchString: string,
- { collections, files }: SearchableData,
+ { collections, files }: SearchableCollectionsAndFiles,
{ locale, holidays, labelledFileTypes }: LocalizedSearchData,
locationTags: Searchable<LocationTag>[],
cities: Searchable<City>[],