Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathi5195e2ac7477
diff --git a/web/apps/photos/src/services/searchService.ts b/web/apps/photos/src/services/searchService.ts
index f869b1e931..943edbbb47 100644
--- a/web/apps/photos/src/services/searchService.ts
+++ b/web/apps/photos/src/services/searchService.ts
@@ -8,7 +8,7 @@ import {
mlStatusSnapshot,
wipSearchPersons,
} from "@/new/photos/services/ml";
-import { parseDateComponents, search } from "@/new/photos/services/search";
+import { createSearchQuery, search } from "@/new/photos/services/search";
import type {
SearchDateComponents,
SearchPerson,
@@ -51,7 +51,9 @@ export const getAutoCompleteSuggestions =
const suggestions: Suggestion[] = [
await getClipSuggestion(searchPhrase),
...getFileTypeSuggestion(searchPhrase),
- ...getDateSuggestion(searchPhrase),
+ // The following functionality has moved to createSearchQuery
+ // - getDateSuggestion(searchPhrase),
+ ...(await createSearchQuery(searchPhrase)),
...getCollectionSuggestion(searchPhrase, collections),
getFileNameSuggestion(searchPhrase, files),
getFileCaptionSuggestion(searchPhrase, files),
diff --git a/web/packages/new/photos/services/search/index.ts b/web/packages/new/photos/services/search/index.ts
index 8f1919974e..6c6dcb5ee6 100644
--- a/web/packages/new/photos/services/search/index.ts
+++ b/web/packages/new/photos/services/search/index.ts
@@ -51,14 +51,10 @@ export const search = async (search: SearchQuery) =>
/**
* A list of holidays - their yearly dates and localized names.
*
- * ---
- *
- * We keep this on the main thread since it uses the t() function for
+ * We need to keep this on the main thread since it uses the t() function for
* localization (although I haven't tried that in a web worker, it might work
- * there too).
- *
- * Also, this cannot be a const since it needs to be evaluated lazily for the
- * t() to work.
+ * there too). Also, it cannot be a const since it needs to be evaluated lazily
+ * for the t() to work.
*/
const holidays = (): DateSearchResult[] => [
{ components: { month: 12, day: 25 }, label: t("CHRISTMAS") },
diff --git a/web/packages/new/photos/services/search/worker.ts b/web/packages/new/photos/services/search/worker.ts
index 5f19f91dba..032024c632 100644
--- a/web/packages/new/photos/services/search/worker.ts
+++ b/web/packages/new/photos/services/search/worker.ts
@@ -12,6 +12,7 @@ import * as chrono from "chrono-node";
import { expose } from "comlink";
import type {
City,
+ DateSearchResult,
Location,
LocationTagData,
SearchDateComponents,
@@ -80,11 +81,6 @@ const dateSuggestion = (
label,
}));
-interface DateSearchResult {
- components: SearchDateComponents;
- label: string;
-}
-
/**
* Try to parse an arbitrary search string into sets of date components.
*
@@ -99,7 +95,7 @@ interface DateSearchResult {
* In addition, also return a formatted representation of the "best" guess at
* the date that was intended by the search string.
*/
-export const parseDateComponents = (
+const parseDateComponents = (
s: string,
locale: string,
holidays: DateSearchResult[],
@@ -137,9 +133,6 @@ const parseChrono = (s: string, locale: string): DateSearchResult[] =>
format.dayPeriod = "short";
}
- // TODO Temp
- console.log("locale", locale);
-
const formatter = new Intl.DateTimeFormat(locale, format);
const label = formatter.format(p.date());
return { components, label };