π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update matcher
Manav Rathi118b828ee510
diff --git a/web/apps/photos/src/services/searchService.ts b/web/apps/photos/src/services/searchService.tsindex 26b07cf937..38641ba9ed 100644--- a/web/apps/photos/src/services/searchService.ts+++ b/web/apps/photos/src/services/searchService.ts@@ -115,22 +115,22 @@ function getHolidaySuggestion(searchPhrase: string): Suggestion[] {return [{label: t("CHRISTMAS"),- value: { month: 11, date: 25 },+ value: { month: 12, date: 25 },type: SuggestionType.DATE,},{label: t("CHRISTMAS_EVE"),- value: { month: 11, date: 24 },+ value: { month: 12, date: 24 },type: SuggestionType.DATE,},{label: t("NEW_YEAR"),- value: { month: 0, date: 1 },+ value: { month: 1, date: 1 },type: SuggestionType.DATE,},{label: t("NEW_YEAR_EVE"),- value: { month: 11, date: 31 },+ value: { month: 12, date: 31 },type: SuggestionType.DATE,},].filter((suggestion) =>diff --git a/web/apps/photos/src/worker/search.worker.ts b/web/apps/photos/src/worker/search.worker.tsindex e32a449dcf..73605432f6 100644--- a/web/apps/photos/src/worker/search.worker.ts+++ b/web/apps/photos/src/worker/search.worker.ts@@ -29,7 +29,8 @@ function isSearchedFile(file: EnteFile, search: Search) {}if (search?.date) {- return isSameDayAnyYear(search.date)(+ return isDateComponentsMatch(+ search.date,new Date(file.metadata.creationTime / 1000),);}@@ -66,19 +67,18 @@ function isSearchedFile(file: EnteFile, search: Search) {return false;}-const isSameDayAnyYear =- (baseDate: SearchDateComponents) => (compareDate: Date) => {- let same = true;+const isDateComponentsMatch = (+ { year, month, day }: SearchDateComponents,+ date: Date,+) => {+ // Components are guaranteed to have at least one component, so start by+ // assuming true.+ let match = true;- if (baseDate.month || baseDate.month === 0) {- same = baseDate.month === compareDate.getMonth();- }- if (same && baseDate.day) {- same = baseDate.day === compareDate.getDate();- }- if (same && baseDate.year) {- same = baseDate.year === compareDate.getFullYear();- }+ if (year) match = date.getFullYear() == year;+ // JS getMonth is 0-indexed.+ if (match && month) match = date.getMonth() + 1 == month;+ if (match && day) match = date.getDate() == day;- return same;- };+ return match;+};diff --git a/web/packages/new/photos/services/search/index.ts b/web/packages/new/photos/services/search/index.tsindex 5aac8dcceb..602546415a 100644--- a/web/packages/new/photos/services/search/index.ts+++ b/web/packages/new/photos/services/search/index.ts@@ -31,7 +31,7 @@ export const parseDateComponents = (const format: Intl.DateTimeFormatOptions = {};if (year) format.year = "numeric";- if (month !== undefined) format.month = "long";+ if (month) format.month = "long";if (day) format.day = "numeric";const formatter = new Intl.DateTimeFormat(undefined, format);diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.tsindex 2cce11126a..c009e546c6 100644--- a/web/packages/new/photos/services/search/types.ts+++ b/web/packages/new/photos/services/search/types.ts@@ -13,15 +13,16 @@ import type { EnteFile } from "../../types/file";*/export interface SearchDateComponents {/**- * The year, if the search string specified one.+ * The year, if the search string specified one. e.g. `2024`.*/year?: number;/**- * The month, if the search string specified one.+ * The month (1 to 12, with December being 12), if the search string+ * specified one.*/month?: number;/**- * The day of the month, if the search string specified one.+ * The day of the month (1 to 31), if the search string specified one.*/day?: number;}