π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
redo wip
Manav Rathia5e1cd2a5c2f
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 6822011a8d..af2be40b2b 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -824,19 +824,24 @@ const Page: React.FC = () => {});try {- updateRemotePrivateMagicMetadata(file, { visibility });- // TODO(AR): Need to trigger a "lite" sync (or update that- // particular file in the reducer state in some other way).-+ const privateMagicMetadata =+ await updateRemotePrivateMagicMetadata(file, {+ visibility,+ });+ // TODO: Trigger a "lite" sync? (or update that particular file+ // in the reducer state in some other way).++ // Keep this as the last operation on the happy path.+ //// See: [Note: File viewer update and dispatch]dispatch({- type: "markUnsyncedVisibilityUpdate",+ type: "unsyncedPrivateMagicMetadataUpdate",fileID,- visibility,+ privateMagicMetadata,});} catch (e) {// Clean pending requests on error (on success,- // "markUnsyncedVisibilityUpdate" will do it for us).+ // "unsyncedPrivateMagicMetadataUpdate" will do it for us).dispatch({type: "markPendingVisibilityUpdate",fileID,diff --git a/web/packages/media/file-metadata.ts b/web/packages/media/file-metadata.tsindex a8126e7eb8..20e3da1eda 100644--- a/web/packages/media/file-metadata.ts+++ b/web/packages/media/file-metadata.ts@@ -6,6 +6,7 @@ import {fileLogID,type EnteFile,type FileMagicMetadata,+ type FilePrivateMagicMetadata,type FilePublicMagicMetadata,} from "@/media/file";import { nullToUndefined } from "@/utils/transform";@@ -485,7 +486,7 @@ export const fileCreationPhotoDate = (export const updateRemotePrivateMagicMetadata = async (file: EnteFile,metadataUpdates: Partial<PrivateMagicMetadata>,-): Promise<FileMagicMetadata> => {+): Promise<FilePrivateMagicMetadata> => {const existingMetadata = filePrivateMagicMetadata(file);const updatedMetadata = { ...(existingMetadata ?? {}), ...metadataUpdates };diff --git a/web/packages/media/file.ts b/web/packages/media/file.tsindex 9499aa4523..d2b8b08f84 100644--- a/web/packages/media/file.ts+++ b/web/packages/media/file.ts@@ -218,6 +218,7 @@ export interface FileMagicMetadataProps {}export type FileMagicMetadata = MagicMetadataCore<FileMagicMetadataProps>;+export type FilePrivateMagicMetadata = MagicMetadataCore<FileMagicMetadataProps>;export interface FilePublicMagicMetadataProps {/**diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.tsindex 4596f9cc0a..69950e7047 100644--- a/web/packages/new/photos/components/gallery/reducer.ts+++ b/web/packages/new/photos/components/gallery/reducer.ts@@ -7,7 +7,7 @@ import {CollectionType,type Collection,} from "@/media/collection";-import type { EnteFile } from "@/media/file";+import type { EnteFile, FilePrivateMagicMetadata } from "@/media/file";import { mergeMetadata } from "@/media/file";import { isArchivedFile, ItemVisibility } from "@/media/file-metadata";import {@@ -239,30 +239,22 @@ export interface GalleryState {* File (IDs) for which there is currently an in-flight archive / unarchive* operation trigged via the file viewer.*- * See also {@link unsyncedVisibilityUpdates}.+ * See also {@link unsyncedPrivateMagicMetadataUpdates}.*/pendingVisibilityUpdates: Set<number>;/**- * Transient updates to the visibility of files whose archive state has been- * toggled by the user in the file viewer, and on remote, but whose effects- * on remote have not yet been synced back to our local DB.+ * Updates to file magic metadata (triggered by some interactive user+ * action) that have already been made to applied to remote, but whose+ * effects on remote have not yet been synced back to our local DB.*- * Each entry from a file ID to `ItemVisibility.archived` (if the file- * should be considered as archived) or `ItemVisibility.visible` (if a file- * that was previously archived has now been unarchived).+ * Each entry from a file ID to the magic metadata that should be used for+ * that file instead of what we get from our local DB.*- * If the remote request succeeds, we still need to sync the files and- * collections in our local DB with the remote state, but that happens in a- * batch when the user exits the viewer. So until that point, these updates- * remain in this unsynced updates map.- *- * Once the remote file and collection sync completes, we can clear this map- * since thereafter the synced files themselves will reflect the latest- * visibility state.- *- * See also {@link pendingVisibilityUpdates}.+ * The next time a sync with remote completes, we clear this map since+ * thereafter the synced files themselves will reflect the latest magic+ * metadata.*/- unsyncedVisibilityUpdates: Map<number, ItemVisibility>;+ unsyncedPrivateMagicMetadataUpdates: Map<number, FilePrivateMagicMetadata>;/*** Transient updates to the favorite status of files that have just been* toggled by the user in the file viewer, and on remote, but whose effects@@ -417,11 +409,9 @@ export type GalleryAction =mark: boolean;}| {- type: "markUnsyncedVisibilityUpdate";+ type: "unsyncedPrivateMagicMetadataUpdate";fileID: number;- // Passing undefined clears any existing entry, concrete values add or- // update one.- visibility: ItemVisibility | undefined;+ privateMagicMetadata: FilePrivateMagicMetadata;}| {type: "markUnsyncedFavoriteUpdate";@@ -466,7 +456,7 @@ const initialGalleryState: GalleryState = {tempDeletedFileIDs: new Set(),tempHiddenFileIDs: new Set(),pendingVisibilityUpdates: new Set(),- unsyncedVisibilityUpdates: new Map(),+ unsyncedPrivateMagicMetadataUpdates: new Map(),unsyncedFavoriteUpdates: new Map(),selectedCollectionSummaryID: undefined,selectedPersonID: undefined,