Skip to content

armgit / ente

Public Imported from GitHub
0

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

Tweak

Manav Rathib02e987fdc17
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 5889db9b31..050f377967 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -48,7 +48,8 @@ import {
SearchBar,
type SearchBarProps,
} from "ente-new/photos/components/SearchBar";
-import SelectedFileOptions, {
+import {
+ SelectedFileOptions,
type CollectionOp,
type FileOp,
} from "ente-new/photos/components/SelectedFileOptions";
@@ -920,22 +921,21 @@ const Page: React.FC = () => {
>
{showSelectionBar ? (
<SelectedFileOptions
- handleCollectionOp={collectionOpsHelper}
- handleFileOp={fileOpHelper}
- showCreateCollectionModal={handleCreateAlbumForOp}
- onOpenCollectionSelector={handleOpenCollectionSelector}
- count={selected.count}
- ownCount={selected.ownCount}
- clearSelection={clearSelection}
barMode={barMode}
+ isInSearchMode={isInSearchMode}
activeCollectionID={activeCollectionID}
selectedCollection={getSelectedCollection(
selected.collectionID,
state.collections,
)}
activeCollectionSummary={activeCollectionSummary}
- isInSearchMode={isInSearchMode}
- isInHiddenSection={barMode == "hidden-albums"}
+ count={selected.count}
+ ownCount={selected.ownCount}
+ handleCollectionOp={collectionOpsHelper}
+ handleFileOp={fileOpHelper}
+ showCreateCollectionModal={handleCreateAlbumForOp}
+ onOpenCollectionSelector={handleOpenCollectionSelector}
+ clearSelection={clearSelection}
/>
) : barMode == "hidden-albums" ? (
<HiddenSectionNavbarContents
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 390566e5c8..af2dd20096 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -495,9 +495,9 @@ export default function PublicCollectionGallery() {
>
{selected.count > 0 ? (
<SelectedFileOptions
- downloadFilesHelper={downloadFilesHelper}
- clearSelection={clearSelection}
count={selected.count}
+ clearSelection={clearSelection}
+ downloadFilesHelper={downloadFilesHelper}
/>
) : (
<SpacedRow sx={{ flex: 1 }}>
@@ -616,9 +616,9 @@ interface SelectedFileOptionsProps {
}
const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
- downloadFilesHelper,
count,
clearSelection,
+ downloadFilesHelper,
}) => (
<Stack
direction="row"
diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsx
index 89ccaf7ba4..7b5762edbc 100644
--- a/web/packages/new/photos/components/SelectedFileOptions.tsx
+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx
@@ -35,24 +35,11 @@ export type FileOp =
| "trash"
| "deletePermanently";
-interface Props {
- handleCollectionOp: (op: CollectionOp) => (...args: any[]) => void;
- handleFileOp: (op: FileOp) => (...args: any[]) => void;
- showCreateCollectionModal: (op: CollectionOp) => () => void;
- /**
- * Callback to open a dialog where the user can choose a collection.
- *
- * The reason for opening the dialog and other properties are passed as the
- * {@link attributes} argument.
- */
- onOpenCollectionSelector: (
- attributes: CollectionSelectorAttributes,
- ) => void;
- count: number;
- ownCount: number;
- clearSelection: () => void;
+interface SelectedFileOptionsProps {
barMode?: GalleryBarMode;
+ isInSearchMode: boolean;
activeCollectionID: number;
+ selectedCollection?: Collection;
/**
* TODO: Need to implement delete-equivalent from shared albums.
*
@@ -75,12 +62,26 @@ interface Props {
* user, even if they are in an album owned by the user.
*/
activeCollectionSummary: CollectionSummary | undefined;
- isInSearchMode: boolean;
- selectedCollection: Collection;
- isInHiddenSection: boolean;
+ count: number;
+ ownCount: number;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ handleCollectionOp: (op: CollectionOp) => (...args: any[]) => void;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ handleFileOp: (op: FileOp) => (...args: any[]) => void;
+ showCreateCollectionModal: (op: CollectionOp) => () => void;
+ /**
+ * Callback to open a dialog where the user can choose a collection.
+ *
+ * The reason for opening the dialog and other properties are passed as the
+ * {@link attributes} argument.
+ */
+ onOpenCollectionSelector: (
+ attributes: CollectionSelectorAttributes,
+ ) => void;
+ clearSelection: () => void;
}
-const SelectedFileOptions = ({
+export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
showCreateCollectionModal,
onOpenCollectionSelector,
handleCollectionOp,
@@ -93,12 +94,9 @@ const SelectedFileOptions = ({
activeCollectionID,
activeCollectionSummary,
isInSearchMode,
- isInHiddenSection,
-}: Props) => {
+}) => {
const { showMiniDialog } = useBaseContext();
- const peopleMode = barMode == "people";
-
const isFavoriteCollection =
!!activeCollectionSummary?.attributes.has("userFavorites");
@@ -114,7 +112,9 @@ const SelectedFileOptions = ({
onSelectCollection: handleCollectionOp("add"),
onCreateCollection: showCreateCollectionModal("add"),
relatedCollectionID:
- isInSearchMode || peopleMode ? undefined : activeCollectionID,
+ isInSearchMode || barMode == "people"
+ ? undefined
+ : activeCollectionID,
});
const trashHandler = () =>
@@ -178,7 +178,9 @@ const SelectedFileOptions = ({
onSelectCollection: handleCollectionOp("move"),
onCreateCollection: showCreateCollectionModal("move"),
relatedCollectionID:
- isInSearchMode || peopleMode ? undefined : activeCollectionID,
+ isInSearchMode || barMode == "people"
+ ? undefined
+ : activeCollectionID,
});
};
@@ -237,7 +239,7 @@ const SelectedFileOptions = ({
</IconButton>
</Tooltip>
</>
- ) : peopleMode ? (
+ ) : barMode == "people" ? (
<>
<Tooltip title={t("download")}>
<IconButton onClick={handleFileOp("download")}>
@@ -302,7 +304,7 @@ const SelectedFileOptions = ({
<DownloadIcon />
</IconButton>
</Tooltip>
- ) : isInHiddenSection ? (
+ ) : barMode == "hidden-albums" ? (
<>
<Tooltip title={t("unhide")}>
<IconButton onClick={unhideToCollection}>
@@ -395,5 +397,3 @@ const SelectedFileOptions = ({
</SpacedRow>
);
};
-
-export default SelectedFileOptions;