π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Rename 2
Manav Rathi9628bf8723a5
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex b1e18c5890..498e79f3b1 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -68,7 +68,7 @@ export type FileListWithViewerProps = {| "collectionNameByID"| "pendingFavoriteUpdates"| "pendingVisibilityUpdates"- | "onFileAndCollectionSyncWithRemote"+ | "onRemoteFilesPull"| "onVisualFeedback"| "onToggleFavorite"| "onFileVisibilityUpdate"@@ -103,7 +103,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({setFilesDownloadProgressAttributesCreator,onSetOpenFileViewer,onSyncWithRemote,- onFileAndCollectionSyncWithRemote,+ onRemoteFilesPull,onVisualFeedback,onToggleFavorite,onFileVisibilityUpdate,@@ -203,7 +203,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({collectionNameByID,pendingFavoriteUpdates,pendingVisibilityUpdates,- onFileAndCollectionSyncWithRemote,+ onRemoteFilesPull,onVisualFeedback,onToggleFavorite,onFileVisibilityUpdate,diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsxindex 16f4c644c5..4336e9076b 100644--- a/web/apps/photos/src/components/Upload.tsx+++ b/web/apps/photos/src/components/Upload.tsx@@ -102,7 +102,7 @@ interface UploadProps {* Called when an action in the uploader requires us to first pull the* latest files and collections from remote.*- * See: [Note: Full sync vs file and collection sync]+ * See: [Note: Full remote pull vs files pull]** Specifically, this is used prior to creating a new album, to obtain* (potential) existing albums from remote so that they can be matched by@@ -111,7 +111,7 @@ interface UploadProps {* This functionality is not needed during uploads to a public album, so* this property is optional; the public albums code need not provide it.*/- onFileAndCollectionSyncWithRemote?: () => Promise<void>;+ onRemoteFilesPull?: () => Promise<void>;/*** Callback invoked when a file is uploaded.*@@ -142,7 +142,7 @@ type UploadType = "files" | "folders" | "zips";export const Upload: React.FC<UploadProps> = ({isFirstUpload,dragAndDropFiles,- onFileAndCollectionSyncWithRemote,+ onRemoteFilesPull,onUploadFile,onShowPlanSelector,showSessionExpiredMessage,@@ -623,7 +623,7 @@ export const Upload: React.FC<UploadProps> = ({}const collections: Collection[] = [];try {- await onFileAndCollectionSyncWithRemote!();+ await onRemoteFilesPull!();const existingCollections = await savedNormalCollections();let index = 0;for (const [diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 74b14eb0b4..65c6d5e9e7 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -128,13 +128,13 @@ import {import { getSelectedFiles, handleFileOp, type FileOp } from "utils/file";/**- * Options to customize the behaviour of the sync with remote that gets- * triggered on various actions within the gallery and its descendants.+ * Options to customize the behaviour of the remote pull that gets triggered on+ * various actions within the gallery and its descendants.*/-interface SyncWithRemoteOpts {- /** Force a sync to happen (default: no) */+interface RemotePullOpts {+ /** Force a pull to happen (default: no) */force?: boolean;- /** Perform the sync without showing a global loading bar (default: no) */+ /** Perform the pull without showing a global loading bar (default: no) */silent?: boolean;}@@ -191,11 +191,15 @@ const Page: React.FC = () => {);const [isFileViewerOpen, setIsFileViewerOpen] = useState(false);- /**`true` if a sync is currently in progress. */- const isSyncing = useRef(false);- /** Set to the {@link SyncWithRemoteOpts} of the last sync that was enqueued- while one was already in progress. */- const resyncOpts = useRef<SyncWithRemoteOpts | undefined>(undefined);+ /**`+ * true` if a remote pull is currently in progress.+ */+ const isPullInProgress = useRef(false);+ /**+ * Set to the {@link RemotePullOpts} of the last pull that was enqueued+ * while one was already in progress.+ */+ const pendingPullOpts = useRef<RemotePullOpts | undefined>(undefined);const [uploadTypeSelectorView, setUploadTypeSelectorView] = useState(false);const [uploadTypeSelectorIntent, setUploadTypeSelectorIntent] =@@ -516,11 +520,11 @@ const Page: React.FC = () => {* 1. This involves a lesser number of API requests, so it reduces the time* the user has to wait for their interactive request to complete.*- * 2. The current implementation {@link syncWithRemote} tries to run only- * only one instance of it is in progress at a time, while each- * invocation of {@link fileAndCollectionSyncWithRemote} is independent.+ * 2. The current implementation {@link remotePull} tries to run only only+ * one instance of it is in progress at a time, while each invocation of+ * {@link remoteFilesPull} is independent.*/- const fileAndCollectionSyncWithRemote = useCallback(async () => {+ const remoteFilesPull = useCallback(async () => {const didUpdateFiles = await pullFiles({onSetCollections: (collections) =>dispatch({ type: "setCollections", collections }),@@ -536,8 +540,8 @@ const Page: React.FC = () => {}}, []);- const syncWithRemote = useCallback(- async (opts?: SyncWithRemoteOpts) => {+ const remotePull = useCallback(+ async (opts?: RemotePullOpts) => {const { force, silent } = opts ?? {};// Pre-flight checks.@@ -554,41 +558,44 @@ const Page: React.FC = () => {// Start or enqueue.let isForced = false;- if (isSyncing.current) {+ if (isPullInProgress.current) {if (force) {isForced = true;} else {- resyncOpts.current = { force, silent };+ pendingPullOpts.current = { force, silent };return;}}- // The sync- isSyncing.current = true;+ // The pull itself.+ isPullInProgress.current = true;try {if (!silent) showLoadingBar();await pullFilesPre();- await fileAndCollectionSyncWithRemote();- // syncWithRemote is called with the force flag set to true before- // doing an upload. So it is possible, say when resuming a pending- // upload, that we get two syncWithRemotes happening in parallel.+ await remoteFilesPull();+ // remotePull is called with the force flag set to true before+ // doing an upload. So it is possible, say when resuming a+ // pending upload, that we get two remote pulls happening in+ // parallel.//- // Do the non-file-related sync only for one of these parallel ones.+ // Do the non-file-related post operations only for one of these+ // parallel ones.if (!isForced) {await pullFilesPost();}} catch (e) {- log.error("syncWithRemote failed", e);+ log.error("Remote pull failed", e);} finally {dispatch({ type: "clearUnsyncedState" });if (!silent) hideLoadingBar();}- isSyncing.current = false;+ isPullInProgress.current = false;- const nextOpts = resyncOpts.current;+ // Enqueue another if needed.+ const nextOpts = pendingPullOpts.current;if (nextOpts) {- resyncOpts.current = undefined;- setTimeout(() => syncWithRemote(nextOpts), 0);+ pendingPullOpts.current = undefined;+ setTimeout(() => remotePull(nextOpts), 0);}},[@@ -596,10 +603,13 @@ const Page: React.FC = () => {hideLoadingBar,router,showSessionExpiredDialog,- fileAndCollectionSyncWithRemote,+ remoteFilesPull,],);+ // TODO(RE): temp alias.+ const syncWithRemote = remotePull;+const setupSelectAllKeyBoardShortcutHandler = () => {const handleKeyUp = (e: KeyboardEvent) => {switch (e.key) {@@ -1055,9 +1065,7 @@ const Page: React.FC = () => {onCloseCollectionSelector={handleCloseCollectionSelector}setLoading={setBlockingLoad}setShouldDisableDropzone={setShouldDisableDropzone}- onFileAndCollectionSyncWithRemote={- fileAndCollectionSyncWithRemote- }+ onRemoteFilesPull={remoteFilesPull}onUploadFile={(file) =>dispatch({ type: "uploadFile", file })}@@ -1136,9 +1144,7 @@ const Page: React.FC = () => {onMarkTempDeleted={handleMarkTempDeleted}onSetOpenFileViewer={setIsFileViewerOpen}onSyncWithRemote={syncWithRemote}- onFileAndCollectionSyncWithRemote={- fileAndCollectionSyncWithRemote- }+ onRemoteFilesPull={remoteFilesPull}onVisualFeedback={handleVisualFeedback}onSelectCollection={handleSelectCollection}onSelectPerson={handleSelectPerson}diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex 90323618fc..f2b75d1794 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -213,16 +213,16 @@ export type FileViewerProps = ModalVisibilityProps & {*/onTriggerSyncWithRemote?: () => void;/**- * Called when an action in the file viewer requires us to sync the local+ * Called when an action in the file viewer requires us to pull the local* files and collections with remote.** Unlike {@link onTriggerSyncWithRemote}, which is a trigger, this function- * returns a promise that will settle once the sync has completed, and thus+ * returns a promise that will settle once the pull has completed, and thus* can be used in interactive operations that indicate activity to the user.*- * See: [Note: Full sync vs file and collection sync]+ * See also: [Note: Full remote pull vs files pull]*/- onFileAndCollectionSyncWithRemote?: () => Promise<void>;+ onRemoteFilesPull?: () => Promise<void>;/*** Called when the user performs an action which does not otherwise have any* immediate visual impact, to acknowledge it.@@ -297,7 +297,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({fileNormalCollectionIDs,collectionNameByID,onTriggerSyncWithRemote,- onFileAndCollectionSyncWithRemote,+ onRemoteFilesPull,onVisualFeedback,onToggleFavorite,onFileVisibilityUpdate,@@ -847,15 +847,15 @@ export const FileViewer: React.FC<FileViewerProps> = ({]);const handleFileMetadataUpdate = useMemo(() => {- return onFileAndCollectionSyncWithRemote+ return onRemoteFilesPull? async () => {- // Wait for the file and collection sync to complete.- await onFileAndCollectionSyncWithRemote();- // Set the flag to trigger the full sync to later.+ // Wait for the files pull to complete.+ await onRemoteFilesPull();+ // Set the flag to trigger the full pull later.handleNeedsRemoteSync();}: undefined;- }, [onFileAndCollectionSyncWithRemote, handleNeedsRemoteSync]);+ }, [onRemoteFilesPull, handleNeedsRemoteSync]);const handleUpdateCaption = useCallback((fileID: number, newCaption: string) => {@@ -886,7 +886,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({onUpdateCaption={handleUpdateCaption}onSelectCollection={handleSelectCollection}onSelectPerson={handleSelectPerson}- {...{ collectionNameByID, onFileAndCollectionSyncWithRemote }}+ {...{ collectionNameByID }}/><MoreMenuopen={!!moreMenuAnchorEl}