π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Doc and tweak
Manav Rathib2df63e499fa
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsxindex cf15dd70ac..44ad90dd18 100644--- a/web/apps/photos/src/components/Upload.tsx+++ b/web/apps/photos/src/components/Upload.tsx@@ -49,6 +49,7 @@ import type { EnteFile } from "ente-media/file";import { UploaderNameInput } from "ente-new/albums/components/UploaderNameInput";import { CollectionMappingChoice } from "ente-new/photos/components/CollectionMappingChoice";import type { CollectionSelectorAttributes } from "ente-new/photos/components/CollectionSelector";+import type { RemotePullOpts } from "ente-new/photos/components/gallery";import { downloadAppDialogAttributes } from "ente-new/photos/components/utils/download";import { savedNormalCollections } from "ente-new/photos/services/collection";import { redirectToCustomerPortal } from "ente-new/photos/services/user-details";@@ -83,7 +84,6 @@ import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";import { UploadProgress } from "./UploadProgress";interface UploadProps {- syncWithRemote: (silent?: boolean) => Promise<void>;closeUploadTypeSelector: () => void;/*** Show the collection selector with the given {@link attributes}.@@ -98,6 +98,13 @@ interface UploadProps {setLoading: SetLoading;setShouldDisableDropzone: (value: boolean) => void;showCollectionSelector?: () => void;+ /**+ * Called when the uploader (or the file watcher) wants to perform a full+ * remote pull.+ *+ * See also {@link onRemoteFilesPull}.+ */+ onRemotePull: (opts?: RemotePullOpts) => Promise<void>;/*** Called when an action in the uploader requires us to first pull the* latest files and collections from remote.@@ -142,6 +149,7 @@ type UploadType = "files" | "folders" | "zips";export const Upload: React.FC<UploadProps> = ({isFirstUpload,dragAndDropFiles,+ onRemotePull,onRemoteFilesPull,onUploadFile,onShowPlanSelector,@@ -362,16 +370,7 @@ export const Upload: React.FC<UploadProps> = ({setDesktopFilePaths(filePaths);};- const requestSyncWithRemote = () => {- props.syncWithRemote().catch((e: unknown) => {- log.error(- "Ignoring error when syncing trash changes with remote",- e,- );- });- };-- watcher.init(upload, requestSyncWithRemote);+ watcher.init(upload, () => void onRemotePull());electron.pendingUploads().then((pending) => {if (!pending) return;@@ -676,13 +675,13 @@ export const Upload: React.FC<UploadProps> = ({) => {uploadManager.prepareForNewUpload(parsedMetadataJSONMap);setUploadProgressView(true);- await props.syncWithRemote(true);+ await onRemotePull({ silent: true });};function postUploadAction() {props.setShouldDisableDropzone(false);uploadRunning.current = false;- props.syncWithRemote();+ void onRemotePull();}const uploadFiles = async (diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 070b68387f..ae4156c663 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -54,6 +54,7 @@ import {GalleryEmptyState,PeopleEmptyState,SearchResultsHeader,+ type RemotePullOpts,} from "ente-new/photos/components/gallery";import {findCollectionCreatingUncategorizedIfNeeded,@@ -128,19 +129,6 @@ import {} from "utils/collection";import { getSelectedFiles, handleFileOp, type FileOp } from "utils/file";-/**- * Options to customize the behaviour of the remote pull that gets triggered on- * various actions within the gallery and its descendants.- */-interface RemotePullOpts {- /**- * Perform the pull without showing a global loading bar- *- * Default: `false`.- */- silent?: boolean;-}-const defaultGalleryContext: GalleryContextType = {setActiveCollectionID: () => null,syncWithRemote: () => null,@@ -511,8 +499,13 @@ const Page: React.FC = () => {/*** Pull latest collections, collection files and trash items from remote.*- * Parallel calls are serialized so that there is only one invocation of the- * underlying {@link pullFiles} at a time.+ * This wraps the vanilla {@link pullFiles} with two adornments:+ *+ * 1. Any local database updates due to the pull are also reflected in state+ * updates to the Gallery's reducer.+ *+ * 2. Parallel calls are serialized so that there is only one invocation of+ * the underlying {@link pullFiles} at a time.** [Note: Full remote pull vs files pull]*@@ -546,6 +539,20 @@ const Page: React.FC = () => {[],);+ /**+ * Perform a serialized full remote pull, also updating our component state+ * to match the updates to the local database.+ *+ * See {@link remoteFilesPull} for the general concept. This is a similar+ * wrapper over the full remote pull sequence which also adds pre-flight+ * checks (e.g. to ensure that the user's session has not expired).+ *+ * This method will usually not throw; exceptions during the pull itself are+ * caught. This is so that this promise can be unguardedly awaited without+ * failing the main operations it forms the tail end of: the remote changes+ * would've already been successfully applied, and possibly transient pull+ * failures should get resolved on the next retry.+ */const remotePull = useCallback(async (opts?: RemotePullOpts) =>remotePullQueue.current.add(async () => {@@ -1028,7 +1035,6 @@ const Page: React.FC = () => {<UploadactiveCollection={activeCollection}- syncWithRemote={(silent) => remotePull({ silent })}closeUploadTypeSelector={setUploadTypeSelectorView.bind(null,false,@@ -1037,6 +1043,7 @@ const Page: React.FC = () => {onCloseCollectionSelector={handleCloseCollectionSelector}setLoading={setBlockingLoad}setShouldDisableDropzone={setShouldDisableDropzone}+ onRemotePull={remotePull}onRemoteFilesPull={remoteFilesPull}onUploadFile={(file) =>dispatch({ type: "uploadFile", file })diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex a7f0f12e03..3f07390b22 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -524,10 +524,10 @@ export default function PublicCollectionGallery() {/>{blockingLoad && <TranslucentLoadingOverlay />}<Upload- syncWithRemote={syncWithRemote}uploadCollection={publicCollection}setLoading={setBlockingLoad}setShouldDisableDropzone={setShouldDisableDropzone}+ onRemotePull={syncWithRemote}onUploadFile={(file) =>setPublicFiles(sortFiles([...publicFiles, file]))}diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.tsindex 24cd7d9be8..c12286b19f 100644--- a/web/apps/photos/src/services/watch.ts+++ b/web/apps/photos/src/services/watch.ts@@ -63,12 +63,12 @@ class FolderWatcher {*/private upload: (collectionName: string, filePaths: string[]) => void;/**- * A function to call when we want to sync with the backend. It will- * initiate the sync but will not await its completion.+ * A function to call when we want to trigger a full remote pull. It will+ * initiate the pull but will not await its completion.** This is passed as a param to {@link init}.*/- private requestSyncWithRemote: () => void;+ private onTriggerRemotePull: () => void;/** A helper function that debounces invocations of {@link runNextEvent}. */private debouncedRunNextEvent: () => void;@@ -83,14 +83,14 @@ class FolderWatcher {* This is only called when we're running in the context of our desktop app.** The caller provides us with the hooks we can use to actually upload the- * files, and to sync with remote (say after deletion).+ * files, and to pull the latest changes from remote (say after deletion).*/init(upload: (collectionName: string, filePaths: string[]) => void,- requestSyncWithRemote: () => void,+ onTriggerRemotePull: () => void,) {this.upload = upload;- this.requestSyncWithRemote = requestSyncWithRemote;+ this.onTriggerRemotePull = onTriggerRemotePull;this.registerListeners();this.syncWithDisk();}@@ -492,7 +492,7 @@ class FolderWatcher {await removeFromCollection(id, files);}- this.requestSyncWithRemote();+ this.onTriggerRemotePull();}}diff --git a/web/packages/gallery/services/files-db.ts b/web/packages/gallery/services/files-db.tsindex ef7c028747..e455fbc701 100644--- a/web/packages/gallery/services/files-db.ts+++ b/web/packages/gallery/services/files-db.ts@@ -36,9 +36,10 @@** Note that even though both of them refer to the same conceptual "files DB",* the actual storage is distinct since both the apps run on separate domains- * and so have their separate IndexedDB storage.+ * and so have their separate IndexedDB storage and thus separate files tables.*- * Still, the key names are (generally) distinct to reduce chances of confusion.+ * Still, the key names are distinct to reduce chances of confusion: the public+ * albums app stores data in keys prefixed with "public-".*/import {diff --git a/web/packages/new/photos/components/gallery/index.tsx b/web/packages/new/photos/components/gallery/index.tsxindex 66edbedb6b..cda89d8d59 100644--- a/web/packages/new/photos/components/gallery/index.tsx+++ b/web/packages/new/photos/components/gallery/index.tsx@@ -24,6 +24,18 @@ import { useMLStatusSnapshot } from "../utils/use-snapshot";import { useWrapAsyncOperation } from "../utils/use-wrap-async";import { GalleryItemsHeaderAdapter, GalleryItemsSummary } from "./ListHeader";+/**+ * Options to customize the behaviour of the remote pull that gets triggered on+ * various actions within the gallery and its descendants.+ */+export interface RemotePullOpts {+ /**+ * Perform the pull without showing a global loading bar+ *+ * Default: `false`.+ */+ silent?: boolean;+}/*** The context in which a selection was made.*