Skip to content

armgit / ente

Public Imported from GitHub
0

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

chore(upload):added-comments

Aswin Asok35be14363d14
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index 919ca4995a..4701091a8e 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -664,10 +664,20 @@ export const Upload: React.FC<UploadProps> = ({
}
};
+ /**
+ *
+ * @param batchResult
+ * @param postUploadTargetCollection
+ * @returns
+ *
+ * Adds successfully uploaded Takeout-favorited files to Favorites, skipping
+ * files whose effective target collection is hidden.
+ */
const handleTakeoutFavoritesPostUpload = async (
batchResult: UploadBatchResult,
postUploadTargetCollection: Collection | undefined,
) => {
+ // Checking if any of the uploaded items have their takeoutFavorited as true.
if (
!batchResult.itemResults.some(
({ takeoutFavorited }) => takeoutFavorited,
@@ -676,21 +686,37 @@ export const Upload: React.FC<UploadProps> = ({
return;
}
+ // Get the list of IDs of hidden collections.
const hiddenCollectionIDs = new Set(
(await savedHiddenCollections()).map(({ id }) => id),
);
+
+ // In some cases, such as when the upload is happening to a non-owned album,
+ // files are first added to the user's own album and then, after upload,
+ // linked to the shared album.
+ //
+ // For such cases, check whether the real intended upload location is a
+ // hidden album and add it to the set.
if (
postUploadTargetCollection &&
isHiddenCollection(postUploadTargetCollection)
) {
hiddenCollectionIDs.add(postUploadTargetCollection.id);
}
+
+ /**
+ * Treating the requestCollectionID as a hidden album because the upload was
+ * initated from the hidden-albums UI.
+ *
+ * savedHiddenCollections will already include hidden collections, but it is not
+ * guaranteed to include every hidden album. So this is also a guard at the UI
+ * level.
+ */
if (props.isInHiddenSection) {
for (const { requestedCollectionID } of batchResult.itemResults) {
hiddenCollectionIDs.add(requestedCollectionID);
}
}
-
const favoritedFiles = favoritedFilesFromUploadBatchResult(
batchResult,
hiddenCollectionIDs,
diff --git a/web/apps/photos/src/services/upload-manager.ts b/web/apps/photos/src/services/upload-manager.ts
index decee23461..70a3f41853 100644
--- a/web/apps/photos/src/services/upload-manager.ts
+++ b/web/apps/photos/src/services/upload-manager.ts
@@ -105,6 +105,12 @@ export const favoritedFilesFromUploadBatchResult = (
): EnteFile[] => {
const filesByID = new Map<number, EnteFile>();
+ /**
+ * Filters items with takeoutFavorited set to true, checks if their final upload
+ * target collection is not hidden, and collects successfully uploaded files
+ * and returns them to be added to the Favorites collection of the user after
+ * de-dupe check by fileID.
+ */
for (const itemResult of batchResult.itemResults) {
if (!itemResult.takeoutFavorited) continue;