Skip to content

armgit / ente

Public Imported from GitHub
0

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

refractor(gallery):removed-excess-code

Aswin Asokbe49c4f835c2
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 70e676bc8e..3d6b7994ad 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -107,6 +107,7 @@ import { shouldShowWhatsNew } from "ente-new/photos/services/changelog";
import {
addToCollection,
addToFavoritesCollection,
+ canAddFilesToCollection,
createAlbum,
createPublicURL,
createQuickLinkCollection,
@@ -115,10 +116,8 @@ import {
updateCollectionCover,
} from "ente-new/photos/services/collection";
import {
- canAddToCollection,
haveOnlySystemCollections,
PseudoCollectionID,
- type CollectionSummary,
} from "ente-new/photos/services/collection-summary";
import exportService from "ente-new/photos/services/export";
import {
@@ -981,11 +980,7 @@ const Page: React.FC = () => {
};
const createOnSelectForCollectionOp =
- (op: CollectionOp) =>
- (
- selectedCollection: Collection,
- selectedCollectionSummary?: CollectionSummary,
- ) => {
+ (op: CollectionOp) => (selectedCollection: Collection) => {
const selectedFiles = getSelectedFiles(selected, filteredFiles);
const userFiles = selectedFiles.filter(
// If a selection is happening, there must be a user.
@@ -1021,12 +1016,10 @@ const Page: React.FC = () => {
const shouldAddInsteadOfMove =
op == "move" &&
- !!selectedCollectionSummary &&
- selectedCollectionSummary.attributes.has("sharedIncoming") &&
- canAddToCollection(selectedCollectionSummary);
+ selectedCollection.owner.id != user!.id &&
+ canAddFilesToCollection(selectedCollection);
if (shouldAddInsteadOfMove) {
- setOpenCollectionSelector(false);
showMiniDialog({
title: t("cannot_move_to_shared_albums"),
message: t("cannot_move_to_shared_albums_message"),
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index 6b08f5abc3..2c7c666fbd 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -83,10 +83,7 @@ export interface CollectionSelectorAttributes {
* Callback invoked when the user selects one the existing collections
* listed in the dialog.
*/
- onSelectCollection: (
- collection: Collection,
- collectionSummary: CollectionSummary,
- ) => void;
+ onSelectCollection: (collection: Collection) => void;
/**
* Callback invoked when the user cancels the collection selection dialog.
*/
@@ -166,7 +163,10 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
(cs) => {
if (cs.id === attributes.sourceCollectionSummaryID) {
return false;
- } else if (attributes.action == "add") {
+ } else if (
+ attributes.action == "add" ||
+ attributes.action == "move"
+ ) {
return canAddToCollection(cs) && cs.type != "userFavorites";
} else if (attributes.action == "upload") {
return (
@@ -180,14 +180,6 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
cs.type == "uncategorized") &&
cs.type != "userFavorites"
);
- } else if (attributes.action == "move") {
- const canAddInsteadOfMove =
- cs.attributes.has("sharedIncoming") &&
- canAddToCollection(cs);
- return (
- (canMoveToCollection(cs) || canAddInsteadOfMove) &&
- cs.type != "userFavorites"
- );
} else {
// "unhide"
return (
@@ -245,13 +237,7 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
attributes;
const handleCollectionSummaryClick = async (id: number) => {
- const collectionSummary = filteredCollections.find((cs) => cs.id == id);
- if (!collectionSummary) return;
-
- onSelectCollection(
- await collectionForCollectionSummaryID(id),
- collectionSummary,
- );
+ onSelectCollection(await collectionForCollectionSummaryID(id));
onClose();
};
diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsx
index f809304311..cf75881f4a 100644
--- a/web/packages/new/photos/components/SelectedFileOptions.tsx
+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx
@@ -136,10 +136,7 @@ interface SelectedFileOptionsProps {
*/
createOnSelectForCollectionOp: (
op: CollectionOp,
- ) => (
- selectedCollection: Collection,
- selectedCollectionSummary?: CollectionSummary,
- ) => void;
+ ) => (selectedCollection: Collection) => void;
/**
* A function called to obtain a handler for the provided {@link op}.
*