Skip to content

armgit / ente

Public Imported from GitHub
0

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

Integrate

Manav Rathiac5fc4b893cf
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index 3592e8a6e3..83fd21d52f 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -3,7 +3,6 @@ import { formattedDate } from "@/base/i18n-date";
import {
FileViewer,
type FileViewerProps,
- type FileViewerToggleArchiveButtonProps,
} from "@/gallery/components/viewer/FileViewer";
import type { Collection } from "@/media/collection";
import { EnteFile } from "@/media/file";
@@ -82,11 +81,12 @@ export type FileListWithViewerProps = {
| "isInHiddenSection"
| "fileCollectionIDs"
| "allCollectionsNameByID"
+ | "pendingVisibilityUpdates"
| "onVisualFeedback"
+ | "onFileVisibilityUpdate"
| "onSelectCollection"
| "onSelectPerson"
- > &
- FileViewerToggleArchiveButtonProps;
+ >;
/**
* A list of files (represented by their thumbnails), along with a file viewer
@@ -111,7 +111,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
fileCollectionIDs,
allCollectionsNameByID,
pendingVisibilityUpdates,
- unsyncedVisibilityUpdates,
setFilesDownloadProgressAttributesCreator,
onFileVisibilityUpdate,
onMarkUnsyncedFavoriteUpdate,
@@ -228,7 +227,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
fileCollectionIDs,
allCollectionsNameByID,
pendingVisibilityUpdates,
- unsyncedVisibilityUpdates,
onVisualFeedback,
onFileVisibilityUpdate,
onSelectCollection,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 12b9a419eb..a2fb7b8bd8 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -819,8 +819,7 @@ const Page: React.FC = () => {
await updateRemotePrivateMagicMetadata(file, {
visibility,
});
- // TODO(AR): Trigger a "lite" sync? (or update that particular
- // file in the reducer state in some other way).
+ // TODO(AR): Trigger a "lite" sync?
dispatch({
type: "markPendingVisibilityUpdate",
@@ -1124,9 +1123,6 @@ const Page: React.FC = () => {
pendingVisibilityUpdates={
state.pendingVisibilityUpdates
}
- unsyncedVisibilityUpdates={
- state.unsyncedVisibilityUpdates
- }
favoriteFileIDs={state.favoriteFileIDs}
setFilesDownloadProgressAttributesCreator={
setFilesDownloadProgressAttributesCreator
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 4bffb8a2a2..5a66b376cc 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -123,35 +123,6 @@ export interface FileViewerAnnotatedFile {
itemData: ItemData;
}
-/**
- * File IDs of for which an update is pending, effects on previous toggles that
- * in this file viewer session, and a callback to trigger the toggle.
- *
- * The toggle archived button will shown in the file actions of the file viewer
- * only if all three of these props are specified.
- */
-export interface FileViewerToggleArchiveButtonProps {
- /**
- * File IDs of for which an update of its visibility is pending.
- */
- pendingVisibilityUpdates?: Set<number>;
- /**
- * Effects of previous visibility togles made in this file viewer session.
- *
- * These changes have already been reflected on remote, but we haven't yet
- * done a sync to update our local DB (the sync will happen in a batch when
- * the file viewer is closed).
- */
- unsyncedVisibilityUpdates?: Map<number, ItemVisibility>;
- /**
- * Update the {@link visibility} of the given {@link file}.
- */
- onFileVisibilityUpdate?: (
- file: EnteFile,
- visibility: ItemVisibility,
- ) => Promise<void>;
-}
-
export type FileViewerProps = ModalVisibilityProps & {
/**
* The currently logged in user, if any.
@@ -208,6 +179,13 @@ export type FileViewerProps = ModalVisibilityProps & {
* in the file actions.
*/
favoriteFileIDs?: Set<number>;
+ /**
+ * File IDs of for which an update of its visibility is pending (e.g. due to
+ * a toggle archived action in the file viewer).
+ *
+ * See also {@link pendingVisibilityUpdates}.
+ */
+ pendingVisibilityUpdates?: Set<number>;
/**
* Called when there was some update performed within the file viewer that
* necessitates us to sync with remote again to fetch the latest updates.
@@ -242,6 +220,18 @@ export type FileViewerProps = ModalVisibilityProps & {
* See also: [Note: File viewer update and dispatch]
*/
onToggleFavorite?: (file: EnteFile) => Promise<void>;
+ /**
+ * Called when {@link visibility} of the given {@link file} should be
+ * updated (when the user activates toggle archived action).
+ *
+ * The toggle archived action is shown only if both
+ * {@link pendingVisibilityUpdates} and {@link onFileVisibilityUpdate} are
+ * provided.
+ */
+ onFileVisibilityUpdate?: (
+ file: EnteFile,
+ visibility: ItemVisibility,
+ ) => Promise<void>;
/**
* Called when the given {@link file} should be downloaded.
*
@@ -274,8 +264,7 @@ export type FileViewerProps = ModalVisibilityProps & {
| "allCollectionsNameByID"
| "onSelectCollection"
| "onSelectPerson"
- > &
- FileViewerToggleArchiveButtonProps;
+ >;
/**
* A PhotoSwipe based image, live photo and video viewer.
@@ -292,7 +281,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({
isInHiddenSection,
favoriteFileIDs,
pendingVisibilityUpdates,
- unsyncedVisibilityUpdates,
fileCollectionIDs,
allCollectionsNameByID,
onTriggerSyncWithRemote,
@@ -769,15 +757,11 @@ export const FileViewer: React.FC<FileViewerProps> = ({
if (
pendingVisibilityUpdates &&
- unsyncedVisibilityUpdates &&
onFileVisibilityUpdate &&
file &&
activeAnnotatedFile.annotation.showArchive
) {
- switch (
- unsyncedVisibilityUpdates.get(file.id) ??
- fileVisibility(file)
- ) {
+ switch (fileVisibility(file)) {
case undefined:
case ItemVisibility.visible:
isArchived = false;
@@ -805,7 +789,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({
return { isArchived, isPendingToggleArchive, toggleArchived };
}, [
pendingVisibilityUpdates,
- unsyncedVisibilityUpdates,
onFileVisibilityUpdate,
onGenericError,
refreshSlideAfterDeleteOrArchive,