Skip to content

armgit / ente

Public Imported from GitHub
0

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

Relay

Manav Rathi9cca314ea924
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index 73064593de..d482074f95 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -68,6 +68,7 @@ export type FileListWithViewerProps = {
| "collectionNameByID"
| "pendingFavoriteUpdates"
| "pendingVisibilityUpdates"
+ | "onFileAndCollectionSyncWithRemote"
| "onVisualFeedback"
| "onToggleFavorite"
| "onFileVisibilityUpdate"
@@ -102,6 +103,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
setFilesDownloadProgressAttributesCreator,
onSetOpenFileViewer,
onSyncWithRemote,
+ onFileAndCollectionSyncWithRemote,
onVisualFeedback,
onToggleFavorite,
onFileVisibilityUpdate,
@@ -201,6 +203,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
collectionNameByID,
pendingFavoriteUpdates,
pendingVisibilityUpdates,
+ onFileAndCollectionSyncWithRemote,
onVisualFeedback,
onToggleFavorite,
onFileVisibilityUpdate,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 6576f1ff6a..0ef8501047 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -520,6 +520,23 @@ const Page: React.FC = () => {
setTimeout(hideLoadingBar, 0);
}, [showLoadingBar, hideLoadingBar]);
+ /**
+ * Sync the local files and collection with remote.
+ *
+ * [Note: Full sync vs file and collection sync]
+ *
+ * This is a subset of the sync which happens in {@link syncWithRemote}, but
+ * in some cases where we know that the changes will not have transitive
+ * effects outside of the locally stored files and collections this is a
+ * better option for interactive operations because:
+ *
+ * 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.
+ */
const fileAndCollectionSyncWithRemote = useCallback(async () => {
const didUpdateFiles = await syncCollectionAndFiles({
onSetCollections: (
@@ -1132,6 +1149,7 @@ const Page: React.FC = () => {
onMarkTempDeleted={handleMarkTempDeleted}
onSetOpenFileViewer={setIsFileViewerOpen}
onSyncWithRemote={syncWithRemote}
+ onFileAndCollectionSyncWithRemote={fileAndCollectionSyncWithRemote}
onVisualFeedback={handleVisualFeedback}
onSelectCollection={handleSelectCollection}
onSelectPerson={handleSelectPerson}
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index aee6191788..094a3ec182 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -161,6 +161,17 @@ export type FileInfoProps = ModalVisibilityProps & {
* batched together into a single sync when the file viewer is closed.
*/
onNeedsRemoteSync: () => void;
+ /**
+ * Called when an action in the file viewer requires us to sync the local
+ * files and collections with remote.
+ *
+ * Unlinke {@link onNeedsRemoteSync}, which is a trigger, this function
+ * returns a promise that will settle once the sync has completed, and thus
+ * can be used in interactive operations that indicate progress to the user.
+ *
+ * See: [Note: Full sync vs file and collection sync]
+ */
+ onFileAndCollectionSyncWithRemote: () => Promise<void>;
/**
* Called when an action on the file info drawer change the caption of the
* given {@link EnteFile}.
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 405e54c024..8f69c207a4 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -268,7 +268,10 @@ export type FileViewerProps = ModalVisibilityProps & {
onSaveEditedImageCopy?: ImageEditorOverlayProps["onSaveEditedCopy"];
} & Pick<
FileInfoProps,
- "collectionNameByID" | "onSelectCollection" | "onSelectPerson"
+ | "collectionNameByID"
+ | "onFileAndCollectionSyncWithRemote"
+ | "onSelectCollection"
+ | "onSelectPerson"
>;
/**
@@ -290,6 +293,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
fileNormalCollectionIDs,
collectionNameByID,
onTriggerSyncWithRemote,
+ onFileAndCollectionSyncWithRemote,
onVisualFeedback,
onToggleFavorite,
onFileVisibilityUpdate,
@@ -900,11 +904,11 @@ export const FileViewer: React.FC<FileViewerProps> = ({
allowMap={haveUser}
showCollections={haveUser && !isInHiddenSection}
fileCollectionIDs={fileNormalCollectionIDs}
- collectionNameByID={collectionNameByID}
onNeedsRemoteSync={handleNeedsRemoteSync}
onUpdateCaption={handleUpdateCaption}
onSelectCollection={handleSelectCollection}
onSelectPerson={handleSelectPerson}
+ {...{ collectionNameByID, onFileAndCollectionSyncWithRemote }}
/>
<MoreMenu
open={!!moreMenuAnchorEl}