π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Integrate
Manav Rathi37765169a4a9
diff --git a/web/packages/new/photos/components/PeopleList.tsx b/web/packages/new/photos/components/PeopleList.tsxindex 161539a52a..1b477c4497 100644--- a/web/packages/new/photos/components/PeopleList.tsx+++ b/web/packages/new/photos/components/PeopleList.tsx@@ -14,6 +14,7 @@ export interface PeopleListProps {/** Optional callback invoked when a particular person is selected. */onSelect?: (person: Person, index: number) => void;}+/*** Shows a list of {@link Person} (named cluster groups).*/diff --git a/web/packages/new/photos/services/ml/cgroups.ts b/web/packages/new/photos/services/ml/cgroups.tsindex 23715eb3b9..50002431c0 100644--- a/web/packages/new/photos/services/ml/cgroups.ts+++ b/web/packages/new/photos/services/ml/cgroups.ts@@ -1,10 +1,11 @@import { masterKeyFromSession } from "@/base/session-store";import { setCGroups } from "../search";import { pullCGroups } from "../user-entity";+import type { FaceCluster } from "./cluster";import { clusterGroups } from "./db";/**- * A cgroup ("cluster group") is a group of clusters (possibly containing a+ * A cgroup ("cluster group") is a group of clusters (possibly containing just a* single cluster) that the user has interacted with.** Interactions include hiding, merging and giving a name and/or a cover photo.@@ -25,15 +26,6 @@ import { clusterGroups } from "./db";** cgroups are synced with remote.*- * While in our local representation we separately maintain clusters and link to- * them from within CGroups by their clusterID, in the remote representation- * clusters themselves don't get synced. Instead, the cgroup entities synced- * with remote contain the clusters within themselves.- *- * That is, a cgroup that gets synced with remote looks something like:- *- * { id, name, clusters: [{ clusterID, faceIDs }] }- **/export interface CGroup {/**@@ -53,12 +45,12 @@ export interface CGroup {*/name: string | undefined;/**- * An unordered set of ids of the clusters that belong to this group.+ * An unordered set ofe clusters that have been assigned to this group.*- * For ergonomics of transportation and persistence this is an array, but it+ * For ease of transportation and persistence this is an array, but it* should conceptually be thought of as a set.*/- clusterIDs: string[];+ assigned: FaceCluster[];/*** True if this cluster group should be hidden.*diff --git a/web/packages/new/photos/services/ml/cluster.ts b/web/packages/new/photos/services/ml/cluster.tsindex bb26c386f6..6fcecedba2 100644--- a/web/packages/new/photos/services/ml/cluster.ts+++ b/web/packages/new/photos/services/ml/cluster.ts@@ -20,7 +20,7 @@ export interface FaceCluster {/*** An unordered set of ids of the faces that belong to this cluster.*- * For ergonomics of transportation and persistence this is an array, but it+ * For ease of transportation and persistence this is an array, but it* should conceptually be thought of as a set.*/faces: string[];@@ -203,7 +203,7 @@ export const clusterFaces = (cgroups.push({id: cluster.id,name: undefined,- clusterIDs: [cluster.id],+ assigned: [cluster],isHidden: false,avatarFaceID: undefined,displayFaceID: topFace.faceID,diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.tsindex d7ac134b7e..9ad329dafe 100644--- a/web/packages/new/photos/services/ml/index.ts+++ b/web/packages/new/photos/services/ml/index.ts@@ -422,13 +422,16 @@ export const wipClusterDebugPageContents = async (const clusterByID = new Map(clusters.map((c) => [c.id, c]));const people = cgroups+ // TODO-Cluster+ .map((cgroup) => ({ ...cgroup, name: cgroup.id })).map((cgroup) => {+ if (!cgroup.name) return undefined;const faceID = ensure(cgroup.displayFaceID);const fileID = ensure(fileIDFromFaceID(faceID));const file = ensure(localFileByID.get(fileID));- const faceIDs = cgroup.clusterIDs- .map((id) => ensure(clusterByID.get(id)))+ const faceIDs = cgroup.assigned+ .map(({ id }) => ensure(clusterByID.get(id))).flatMap((cluster) => cluster.faces);const fileIDs = faceIDs.map((faceID) => fileIDFromFaceID(faceID))@@ -443,6 +446,7 @@ export const wipClusterDebugPageContents = async (displayFaceFile: file,};})+ .filter((c) => !!c).sort((a, b) => b.faceIDs.length - a.faceIDs.length);_wip_isClustering = false;@@ -599,23 +603,24 @@ const workerDidProcessFileOrIdle = throttled(updateMLStatusSnapshot, 2000);/*** A massaged version of {@link CGroup} suitable for being shown in the UI.*- * While cgroups are synced with remote, they do not directly correspond to- * "people" (this is ignoring the other issue that the cluster groups may be for- * non-human faces too). CGroups represent both positive and negative feedback,- * and the negations are specifically meant so that they're not shown in the UI.+ * The cgroups synced with remote do not directly correspond to "people".+ * CGroups represent both positive and negative feedback, where the negations+ * are specifically feedback meant so that we do not show the corresponding+ * cluster in the UI.** So while each person has an underlying cgroups, not all cgroups have a* corresponding person.*- * Beyond this, a {@link Person} object has data converted into a format that- * the UI can use directly and efficiently (as compared to a {@link CGroup},- * which is tailored for transmission and storage).+ * Beyond this semantic difference, there is also data massaging: a+ * {@link Person} has data converted into a format that the UI can directly and+ * efficiently use, as compared to a {@link CGroup}, which is tailored for+ * transmission and storage.*/export interface Person {/** Unique ID (nanoid) of the underlying {@link CGroup}. */id: string;- /** If this is a named person, then their name. */- name?: string;+ /** The name of the person. */+ name: string;/** The files in which this face occurs. */files: number[];/**diff --git a/web/packages/new/photos/services/user-entity.ts b/web/packages/new/photos/services/user-entity.tsindex fab3f731ea..88b494fcf6 100644--- a/web/packages/new/photos/services/user-entity.ts+++ b/web/packages/new/photos/services/user-entity.ts@@ -109,16 +109,12 @@ export const savedLocationTags = async () =>* the cgroup specific entity key.*/export const pullCGroups = (masterKey: Uint8Array) => {- const parse = async (id: string, data: Uint8Array): Promise<CGroup> => {- const r = RemoteCGroup.parse(JSON.parse(await gunzip(data)));- return {- id,- name: r.name,- clusterIDs: r.assigned.map(({ id }) => id),- isHidden: r.isHidden,- avatarFaceID: r.avatarFaceID,- };- };+ const parse = async (id: string, data: Uint8Array): Promise<CGroup> => ({+ id,+ name: undefined,+ avatarFaceID: undefined,+ ...RemoteCGroup.parse(JSON.parse(await gunzip(data))),+ });const processBatch = async (entities: UserEntityChange[]) =>await applyCGroupDiff(