Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Rename 3

Manav Rathi3acb04f4cc1a
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index 498e79f3b1..6c512e75f2 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -44,9 +44,10 @@ export type FileListWithViewerProps = {
*/
onSetOpenFileViewer?: (open: boolean) => void;
/**
- * Called when an action in the file viewer requires us to sync with remote.
+ * Called when an action in the file viewer requires us to perform a full
+ * pull from remote.
*/
- onSyncWithRemote: () => Promise<void>;
+ onRemotePull: () => Promise<void>;
} & Pick<
FileListProps,
| "mode"
@@ -102,7 +103,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
pendingVisibilityUpdates,
setFilesDownloadProgressAttributesCreator,
onSetOpenFileViewer,
- onSyncWithRemote,
+ onRemotePull,
onRemoteFilesPull,
onVisualFeedback,
onToggleFavorite,
@@ -134,9 +135,9 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
setOpenFileViewer(false);
}, []);
- const handleTriggerSyncWithRemote = useCallback(
- () => void onSyncWithRemote(),
- [onSyncWithRemote],
+ const handleTriggerRemotePull = useCallback(
+ () => void onRemotePull(),
+ [onRemotePull],
);
const handleDownload = useCallback(
@@ -210,7 +211,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
onSelectCollection,
onSelectPerson,
}}
- onTriggerSyncWithRemote={handleTriggerSyncWithRemote}
+ onTriggerRemotePull={handleTriggerRemotePull}
onDownload={handleDownload}
onDelete={handleDelete}
onSaveEditedImageCopy={handleSaveEditedImageCopy}
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 65c6d5e9e7..b906cb66a5 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -326,17 +326,15 @@ const Page: React.FC = () => {
collectionFiles: await savedCollectionFiles(),
trashItems: await savedTrashItems(),
});
- await syncWithRemote({ force: true });
+ await remotePull({ force: true });
setIsFirstLoad(false);
setJustSignedUp(false);
syncIntervalID = setInterval(
- () => syncWithRemote({ silent: true }),
+ () => remotePull({ silent: true }),
5 * 60 * 1000 /* 5 minutes */,
);
if (electron) {
- electron.onMainWindowFocus(() =>
- syncWithRemote({ silent: true }),
- );
+ electron.onMainWindowFocus(() => remotePull({ silent: true }));
if (await shouldShowWhatsNew(electron)) showWhatsNew();
}
})();
@@ -607,9 +605,6 @@ const Page: React.FC = () => {
],
);
- // TODO(RE): temp alias.
- const syncWithRemote = remotePull;
-
const setupSelectAllKeyBoardShortcutHandler = () => {
const handleKeyUp = (e: KeyboardEvent) => {
switch (e.key) {
@@ -683,7 +678,7 @@ const Page: React.FC = () => {
);
}
clearSelection();
- await syncWithRemote({ silent: true });
+ await remotePull({ silent: true });
} catch (e) {
onGenericError(e);
} finally {
@@ -724,7 +719,7 @@ const Page: React.FC = () => {
);
}
clearSelection();
- await syncWithRemote({ silent: true });
+ await remotePull({ silent: true });
} catch (e) {
onGenericError(e);
} finally {
@@ -908,7 +903,7 @@ const Page: React.FC = () => {
...defaultGalleryContext,
setActiveCollectionID: handleShowCollectionSummary,
syncWithRemote: (force, silent) =>
- syncWithRemote({ force, silent }),
+ remotePull({ force, silent }),
setBlockingLoad,
photoListHeader,
user,
@@ -1055,7 +1050,7 @@ const Page: React.FC = () => {
<Upload
activeCollection={activeCollection}
syncWithRemote={(force, silent) =>
- syncWithRemote({ force, silent })
+ remotePull({ force, silent })
}
closeUploadTypeSelector={setUploadTypeSelectorView.bind(
null,
@@ -1143,7 +1138,7 @@ const Page: React.FC = () => {
}
onMarkTempDeleted={handleMarkTempDeleted}
onSetOpenFileViewer={setIsFileViewerOpen}
- onSyncWithRemote={syncWithRemote}
+ onRemotePull={remotePull}
onRemoteFilesPull={remoteFilesPull}
onVisualFeedback={handleVisualFeedback}
onSelectCollection={handleSelectCollection}
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 12a2b2d3e2..a7f0f12e03 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -519,7 +519,7 @@ export default function PublicCollectionGallery() {
setFilesDownloadProgressAttributesCreator={
setFilesDownloadProgressAttributesCreator
}
- onSyncWithRemote={syncWithRemote}
+ onRemotePull={syncWithRemote}
onVisualFeedback={handleVisualFeedback}
/>
{blockingLoad && <TranslucentLoadingOverlay />}
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index f2b75d1794..d7da4f2555 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -199,24 +199,26 @@ export type FileViewerProps = ModalVisibilityProps & {
fileNormalCollectionIDs?: FileInfoProps["fileCollectionIDs"];
/**
* Called when there was some update performed within the file viewer that
- * necessitates us to sync with remote again to fetch the latest updates.
+ * necessitates us to pull the latest updates with remote.
*
- * This is called lazily, and at most once, when the file viewer is closing
- * if any changes were made in the file info panel of the file viewer for
- * any of the files that the user was viewing (e.g. if they changed the
- * caption). Those changes have already been applied to both remote and to
- * the in-memory file object used by the file viewer; this callback is to
- * trigger a sync so that our local database also gets up to speed.
+ * This is called when the file viewer is closing if any changes were made
+ * in the file info panel of the file viewer for any of the files that the
+ * user was viewing (e.g. if they changed the caption).
+ *
+ * Those changes have already been applied to both remote, and likely
+ * already also to our local state via {@link onRemoteFilesPull}. This this
+ * callback is to trigger a full pull so that any discrepancies in local
+ * database also gets up to speed if needed.
*
* If we're in a context where edits are not possible, e.g. {@link user} is
- * not defined, then this prop is not used.
+ * not defined, then this prop is not used and need not be provided.
*/
- onTriggerSyncWithRemote?: () => void;
+ onTriggerRemotePull?: () => void;
/**
* 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
+ * Unlike {@link onTriggerRemotePull}, which is a trigger, this function
* 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.
*
@@ -296,7 +298,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
pendingVisibilityUpdates,
fileNormalCollectionIDs,
collectionNameByID,
- onTriggerSyncWithRemote,
+ onTriggerRemotePull,
onRemoteFilesPull,
onVisualFeedback,
onToggleFavorite,
@@ -357,14 +359,17 @@ export const FileViewer: React.FC<FileViewerProps> = ({
const [isFullscreen, setIsFullscreen] = useState(false);
- // If `true`, then we need to trigger a sync with remote when we close.
- const [, setNeedsSync] = useState(false);
+ // If `true`, then we need to trigger a pull from remote when we close.
+ const [, setNeedsRemotePull] = useState(false);
- const handleNeedsRemoteSync = useCallback(() => setNeedsSync(true), []);
+ const handleNeedsRemotePull = useCallback(
+ () => setNeedsRemotePull(true),
+ [],
+ );
const handleClose = useCallback(() => {
- setNeedsSync((needSync) => {
- if (needSync) onTriggerSyncWithRemote?.();
+ setNeedsRemotePull((needsPull) => {
+ if (needsPull) onTriggerRemotePull?.();
return false;
});
setOpenFileInfo(false);
@@ -375,7 +380,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
setOpenConfirmDelete(false);
setOpenShortcuts(false);
onClose();
- }, [onTriggerSyncWithRemote, onClose]);
+ }, [onTriggerRemotePull, onClose]);
const handleViewInfo = useCallback(
(annotatedFile: FileViewerAnnotatedFile) => {
@@ -439,7 +444,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
const handleDelete = async () => {
const file = activeAnnotatedFile!.file;
await onDelete!(file);
- handleNeedsRemoteSync();
+ handleNeedsRemotePull();
};
// Not memoized since it uses the frequently changing `activeAnnotatedFile`.
@@ -604,8 +609,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({
({ file }: FileViewerAnnotatedFile) =>
onToggleFavorite!(file)
.catch(onGenericError)
- .finally(handleNeedsRemoteSync),
- [onToggleFavorite, onGenericError, handleNeedsRemoteSync],
+ .finally(handleNeedsRemotePull),
+ [onToggleFavorite, onGenericError, handleNeedsRemotePull],
);
const updateFullscreenStatus = useCallback(() => {
@@ -686,7 +691,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
? ItemVisibility.visible
: ItemVisibility.archived,
)
- .then(handleNeedsRemoteSync)
+ .then(handleNeedsRemotePull)
.catch(onGenericError);
};
}
@@ -696,7 +701,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
pendingVisibilityUpdates,
onFileVisibilityUpdate,
onGenericError,
- handleNeedsRemoteSync,
+ handleNeedsRemotePull,
handleMoreMenuCloseIfNeeded,
activeAnnotatedFile,
]);
@@ -852,10 +857,10 @@ export const FileViewer: React.FC<FileViewerProps> = ({
// Wait for the files pull to complete.
await onRemoteFilesPull();
// Set the flag to trigger the full pull later.
- handleNeedsRemoteSync();
+ handleNeedsRemotePull();
}
: undefined;
- }, [onRemoteFilesPull, handleNeedsRemoteSync]);
+ }, [onRemoteFilesPull, handleNeedsRemotePull]);
const handleUpdateCaption = useCallback(
(fileID: number, newCaption: string) => {