π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove workaround
Manav Rathi7227a4b0840d
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.tsindex 0c841e643d..b2b33a26e2 100644--- a/web/packages/new/photos/services/ml/index.ts+++ b/web/packages/new/photos/services/ml/index.ts@@ -27,7 +27,7 @@ import { deleteUserEntity } from "../user-entity/remote";import type { FaceCluster } from "./cluster";import { regenerateFaceCrops } from "./crop";import { clearMLDB, getFaceIndex, getIndexableAndIndexedCounts } from "./db";-import { reconstructPeople, type Person } from "./people";+import { filterNamedPeople, reconstructPeople, type Person } from "./people";import { MLWorker } from "./worker";import type { CLIPMatches } from "./worker-types";@@ -575,11 +575,7 @@ const updatePeople = async () => {const people = await reconstructPeople();// Notify the search subsystem of the update (search only uses named ones).- setSearchPeople(- people- .map((p) => (p.name ? { name: p.name, person: p } : undefined))- .filter((p) => !!p),- );+ setSearchPeople(filterNamedPeople(people));// Update our in-memory list of people.setPeopleSnapshot(people);diff --git a/web/packages/new/photos/services/ml/people.ts b/web/packages/new/photos/services/ml/people.tsindex ef30e36707..a5e6b80733 100644--- a/web/packages/new/photos/services/ml/people.ts+++ b/web/packages/new/photos/services/ml/people.ts@@ -125,6 +125,13 @@ export type Person = (displayFaceFile: EnteFile;};+/**+ * A {@link Person} whose name is not empty.+ */+export type NamedPerson = Person & {+ name: string;+};+/*** Construct in-memory people using the data present locally, ignoring faces* belonging to deleted and hidden files.@@ -272,3 +279,19 @@ export const reconstructPeople = async (): Promise<Person[]> => {*/const resolvedAvatarFaceID = (avatarFaceID: string | undefined) =>avatarFaceID?.split("_").length == 1 ? undefined : avatarFaceID;++/**+ * Return only those from amongst {@link people} that have a name defined.+ *+ * @param people List of all people, named and unnamed.+ */+export const filterNamedPeople = (people: Person[]): NamedPerson[] => {+ const namedPeople: NamedPerson[] = [];+ for (const person of people) {+ const name = person.name;+ if (name) {+ namedPeople.push({ ...person, name });+ }+ }+ return namedPeople;+};diff --git a/web/packages/new/photos/services/search/index.ts b/web/packages/new/photos/services/search/index.tsindex e18b91f837..07e3cd326d 100644--- a/web/packages/new/photos/services/search/index.ts+++ b/web/packages/new/photos/services/search/index.ts@@ -4,12 +4,12 @@ import { ComlinkWorker } from "@/base/worker/comlink-worker";import { FileType } from "@/media/file-type";import i18n, { t } from "i18next";import { clipMatches, isMLEnabled, isMLSupported } from "../ml";+import type { NamedPerson } from "../ml/people";import type {LabelledFileType,LabelledSearchDateComponents,LocalizedSearchData,SearchCollectionsAndFiles,- SearchPerson,SearchSuggestion,} from "./types";import type { SearchWorker } from "./worker";@@ -60,7 +60,7 @@ export const setSearchCollectionsAndFiles = (cf: SearchCollectionsAndFiles) =>/*** Set the (named) people that we should search across.*/-export const setSearchPeople = (people: SearchPerson[]) =>+export const setSearchPeople = (people: NamedPerson[]) =>void worker().then((w) => w.setPeople(people));/**diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.tsindex 49b2c35839..9c9123366f 100644--- a/web/packages/new/photos/services/search/types.ts+++ b/web/packages/new/photos/services/search/types.ts@@ -114,16 +114,3 @@ export type City = Location & {/** Name of the city. */name: string;};--export type NamedPerson = Person & {- name: string;-};--/**- * What we want is NamedPerson, but I can't get it to TypeScript to accept it in- * our usage contexts. This is a workaround.- */-export interface SearchPerson {- person: Person;- name: string;-}diff --git a/web/packages/new/photos/services/search/worker.ts b/web/packages/new/photos/services/search/worker.tsindex 03e39c1d4c..ca12c27168 100644--- a/web/packages/new/photos/services/search/worker.ts+++ b/web/packages/new/photos/services/search/worker.ts@@ -10,6 +10,7 @@ import type { Component } from "chrono-node";import * as chrono from "chrono-node";import { expose } from "comlink";import { z } from "zod";+import type { NamedPerson } from "../ml/people";import {pullUserEntities,savedLocationTags,@@ -22,7 +23,6 @@ import type {LocalizedSearchData,SearchCollectionsAndFiles,SearchDateComponents,- SearchPerson,SearchSuggestion,} from "./types";@@ -37,7 +37,7 @@ export class SearchWorker {collections: [],files: [],};- private people: SearchPerson[] = [];+ private people: NamedPerson[] = [];/*** Fetch any state we might need when the actual search happens.@@ -64,7 +64,7 @@ export class SearchWorker {/*** Set the (named) people that we should search across.*/- setPeople(people: SearchPerson[]) {+ setPeople(people: NamedPerson[]) {this.people = people;}@@ -122,7 +122,7 @@ const suggestionsForString = (re: RegExp,searchString: string,{ collections, files }: SearchCollectionsAndFiles,- people: SearchPerson[],+ people: NamedPerson[],{ locale, holidays, labelledFileTypes }: LocalizedSearchData,locationTags: LocationTag[],cities: City[],@@ -198,11 +198,11 @@ const fileCaptionSuggestion = (const peopleSuggestions = (re: RegExp,- people: SearchPerson[],+ people: NamedPerson[],): SearchSuggestion[] =>people- .filter((sp) => re.test(sp.name))- .map((sp) => ({ type: "person", person: sp.person, label: sp.name }));+ .filter(({ name }) => re.test(name))+ .map((person) => ({ type: "person", person, label: person.name }));const dateSuggestions = (s: string,