Skip to content

armgit / ente

Public Imported from GitHub
0

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

st 2

Manav Rathi067e44e10a55
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsx
index ecb84371bf..b68f603744 100644
--- a/web/apps/photos/src/components/PhotoFrame.tsx
+++ b/web/apps/photos/src/components/PhotoFrame.tsx
@@ -121,7 +121,10 @@ export type PhotoFrameProps = Pick<
*
* Not set in the context of the shared albums app.
*/
- markUnsyncedFavoriteUpdate?: (fileID: number, isFavorite: boolean) => void;
+ onMarkUnsyncedFavoriteUpdate?: (
+ fileID: number,
+ isFavorite: boolean,
+ ) => void;
/**
* Called when the component wants to mark the given files as deleted in the
* the in-memory, unsynced, state maintained by the top level gallery.
@@ -131,7 +134,7 @@ export type PhotoFrameProps = Pick<
*
* Not set in the context of the shared albums app.
*/
- markTempDeleted?: (files: EnteFile[]) => void;
+ onMarkTempDeleted?: (files: EnteFile[]) => void;
/** This will be set if mode is not "people". */
activeCollectionID: number;
/** This will be set if mode is "people". */
@@ -155,8 +158,8 @@ const PhotoFrame = ({
setSelected,
selected,
favoriteFileIDs,
- markUnsyncedFavoriteUpdate,
- markTempDeleted,
+ onMarkUnsyncedFavoriteUpdate,
+ onMarkTempDeleted,
activeCollectionID,
activePersonID,
enableDownload,
@@ -554,12 +557,13 @@ const PhotoFrame = ({
isInHiddenSection={isInHiddenSection}
disableDownload={!enableDownload}
onTriggerSyncWithRemote={handleTriggerSyncWithRemote}
- onMarkUnsyncedFavoriteUpdate={markUnsyncedFavoriteUpdate}
onSaveEditedImageCopy={handleSaveEditedImageCopy}
{...{
favoriteFileIDs,
fileCollectionIDs,
allCollectionsNameByID,
+ onMarkUnsyncedFavoriteUpdate,
+ onMarkTempDeleted,
onSelectCollection,
onSelectPerson,
}}
@@ -592,8 +596,8 @@ const PhotoFrame = ({
enableDownload={enableDownload}
{...{
favoriteFileIDs,
- markUnsyncedFavoriteUpdate,
- markTempDeleted,
+ onMarkUnsyncedFavoriteUpdate,
+ onMarkTempDeleted,
setFilesDownloadProgressAttributesCreator,
fileCollectionIDs,
allCollectionsNameByID,
diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsx
index 3454d11ae7..2868a0f5d4 100644
--- a/web/apps/photos/src/components/PhotoViewer/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/index.tsx
@@ -76,8 +76,8 @@ import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";
export type PhotoViewerProps = Pick<
PhotoFrameProps,
| "favoriteFileIDs"
- | "markUnsyncedFavoriteUpdate"
- | "markTempDeleted"
+ | "onMarkUnsyncedFavoriteUpdate"
+ | "onMarkTempDeleted"
| "fileCollectionIDs"
| "allCollectionsNameByID"
| "onSelectCollection"
@@ -132,8 +132,8 @@ export const PhotoViewer: React.FC<PhotoViewerProps> = ({
gettingData,
forceConvertItem,
favoriteFileIDs,
- markUnsyncedFavoriteUpdate,
- markTempDeleted,
+ onMarkUnsyncedFavoriteUpdate,
+ onMarkTempDeleted,
isTrashCollection,
isInHiddenSection,
enableDownload,
@@ -511,16 +511,16 @@ export const PhotoViewer: React.FC<PhotoViewerProps> = ({
const isFavorite = favoriteFileIDs!.has(file.id);
if (!isFavorite) {
- markUnsyncedFavoriteUpdate(file.id, true);
+ onMarkUnsyncedFavoriteUpdate(file.id, true);
void addToFavorites(file).catch((e: unknown) => {
log.error("Failed to add favorite", e);
- markUnsyncedFavoriteUpdate(file.id, undefined);
+ onMarkUnsyncedFavoriteUpdate(file.id, undefined);
});
} else {
- markUnsyncedFavoriteUpdate(file.id, false);
+ onMarkUnsyncedFavoriteUpdate(file.id, false);
void removeFromFavorites(file).catch((e: unknown) => {
log.error("Failed to remove favorite", e);
- markUnsyncedFavoriteUpdate(file.id, undefined);
+ onMarkUnsyncedFavoriteUpdate(file.id, undefined);
});
}
@@ -538,7 +538,7 @@ export const PhotoViewer: React.FC<PhotoViewerProps> = ({
const handleDeleteFile = async () => {
const file = fileToDelete!;
await moveToTrash([file]);
- markTempDeleted?.([file]);
+ onMarkTempDeleted?.([file]);
updateItems(items.filter((item) => item.id !== file.id));
setFileToDelete(undefined);
needUpdate.current = true;
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index d4a08eed7f..5b88e5e9e3 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -695,7 +695,7 @@ const Page: React.FC = () => {
await handleFileOps(
ops,
toProcessFiles,
- (files) => dispatch({ type: "markTempDeleted", files }),
+ handleMarkTempDeleted,
() => dispatch({ type: "clearTempDeleted" }),
(files) => dispatch({ type: "markTempHidden", files }),
() => dispatch({ type: "clearTempHidden" }),
@@ -793,6 +793,21 @@ const Page: React.FC = () => {
});
};
+ const handleMarkUnsyncedFavoriteUpdate = useCallback(
+ (fileID: number, isFavorite: boolean) =>
+ dispatch({
+ type: "markUnsyncedFavoriteUpdate",
+ fileID,
+ isFavorite,
+ }),
+ [],
+ );
+
+ const handleMarkTempDeleted = useCallback(
+ (files: EnteFile[]) => dispatch({ type: "markTempDeleted", files }),
+ [],
+ );
+
const handleSelectCollection = useCallback(
(collectionID: number) =>
dispatch({
@@ -1032,20 +1047,11 @@ const Page: React.FC = () => {
mode={barMode}
modePlus={isInSearchMode ? "search" : barMode}
files={filteredFiles}
+ // TODO: Warning: Doesn't have stable identity.
syncWithRemote={syncWithRemote}
setSelected={setSelected}
selected={selected}
favoriteFileIDs={state.favoriteFileIDs}
- markUnsyncedFavoriteUpdate={(fileID, isFavorite) =>
- dispatch({
- type: "markUnsyncedFavoriteUpdate",
- fileID,
- isFavorite,
- })
- }
- markTempDeleted={(files) =>
- dispatch({ type: "markTempDeleted", files })
- }
setIsPhotoSwipeOpen={setIsPhotoSwipeOpen}
activeCollectionID={activeCollectionID}
activePersonID={activePerson?.id}
@@ -1060,6 +1066,10 @@ const Page: React.FC = () => {
setFilesDownloadProgressAttributesCreator
}
selectable={true}
+ onMarkUnsyncedFavoriteUpdate={
+ handleMarkUnsyncedFavoriteUpdate
+ }
+ onMarkTempDeleted={handleMarkTempDeleted}
onSelectCollection={handleSelectCollection}
onSelectPerson={handleSelectPerson}
/>
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index eb01c66ba7..fdb262bac1 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -122,18 +122,26 @@ export type FileViewerProps = ModalVisibilityProps & {
onTriggerSyncWithRemote?: () => void;
/**
* Called when the viewer wants to update the in-memory, unsynced, favorite
- * status of a file.
+ * status of a file maintained by the top level gallery. For more details,
+ * see {@link unsyncedFavoriteUpdates} in the gallery reducer's
+ * documentation.
*
- * For more details, see {@link unsyncedFavoriteUpdates} in the gallery
- * reducer's documentation.
- *
- * If this is not provided then the favorite toggle button will not be shown
- * in the file actions.
+ * If this is not provided then the toggle favorite action will not be
+ * shown.
*/
onMarkUnsyncedFavoriteUpdate?: (
fileID: number,
isFavorite: boolean,
) => void;
+ /**
+ * Called when the viewer wants to mark the given files as deleted in the
+ * the in-memory, unsynced, state maintained by the top level gallery. For
+ * more details, see {@link unsyncedFavoriteUpdates} in the gallery
+ * reducer's documentation.
+ *
+ * If this is not provided then the delete action will not be shown.
+ */
+ onMarkTempDeleted?: (files: EnteFile[]) => void;
/**
* Called when the user edits an image in the image editor and asks us to
* save their edits as a copy.
@@ -171,6 +179,8 @@ const FileViewer: React.FC<FileViewerProps> = ({
onSelectPerson,
onTriggerSyncWithRemote,
onMarkUnsyncedFavoriteUpdate,
+ // TODO
+ // onMarkTempDeleted,
onSaveEditedImageCopy,
}) => {
const pswpRef = useRef<FileViewerPhotoSwipe | undefined>();