Skip to content

armgit / ente

Public Imported from GitHub
0

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

add(UploadConfirmationDialog):add-partner-sharing-toggle

Aswin Asok82d17f0c2eb8
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index 7e93797f40..30ef33f639 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -177,6 +177,8 @@ interface UploadFilesOptions {
postUploadTargetCollection?: Collection;
/** Whether Takeout-favorited uploads should be added to Favorites. */
importTakeoutFavorites?: boolean;
+ /** Whether media originating from Google Photos partner sharing is uploaded. */
+ includePartnerSharedFiles?: boolean;
}
interface NewCollectionsOptions {
@@ -206,6 +208,7 @@ interface UploadConfirmation {
albumCount: number;
isTakeout: boolean;
importFavorites: boolean;
+ includePartnerSharedFiles: boolean;
}
/**
@@ -350,6 +353,8 @@ export const Upload: React.FC<UploadProps> = ({
);
/** The confirmed favorites choice for retrying the current batch. */
const retryImportTakeoutFavorites = useRef(true);
+ /** The confirmed partner-sharing choice for retrying the current batch. */
+ const retryIncludePartnerSharedFiles = useRef(false);
/**
* `true` if we've activated one hidden {@link Inputs} that allow the user
@@ -856,6 +861,7 @@ export const Upload: React.FC<UploadProps> = ({
albumCount: 1,
isTakeout,
importFavorites: true,
+ includePartnerSharedFiles: true,
});
} catch (e) {
if (uploadItemsAndPaths.current !== uploadItemAndPaths) return;
@@ -868,6 +874,7 @@ export const Upload: React.FC<UploadProps> = ({
collection: Collection,
uploadItemAndPaths: UploadItemAndPath[],
importTakeoutFavorites: boolean,
+ includePartnerSharedFiles = false,
) => {
try {
preCollectionCreationAction();
@@ -899,6 +906,7 @@ export const Upload: React.FC<UploadProps> = ({
? undefined
: collection,
importTakeoutFavorites,
+ includePartnerSharedFiles,
},
);
if (uploadItemsAndPaths.current === uploadItemAndPaths) {
@@ -977,6 +985,7 @@ export const Upload: React.FC<UploadProps> = ({
albumCount: collectionNameToUploadItems.size,
isTakeout,
importFavorites: true,
+ includePartnerSharedFiles: true,
});
} catch (e) {
if (uploadItemsAndPaths.current !== uploadItemAndPaths) return;
@@ -990,6 +999,7 @@ export const Upload: React.FC<UploadProps> = ({
collectionNameToUploadItems: Map<string, UploadItemAndPath[]>,
{ includeHiddenCollections, createHidden }: NewCollectionsOptions,
importTakeoutFavorites: boolean,
+ includePartnerSharedFiles = false,
) => {
preCollectionCreationAction();
let uploadItemsWithCollection: UploadItemWithCollection[] = [];
@@ -1042,6 +1052,7 @@ export const Upload: React.FC<UploadProps> = ({
persistPendingUploads: true,
postUploadTargetCollection: undefined,
importTakeoutFavorites,
+ includePartnerSharedFiles,
},
);
if (uploadItemsAndPaths.current === uploadItemAndPaths) {
@@ -1054,12 +1065,14 @@ export const Upload: React.FC<UploadProps> = ({
if (!confirmation) return;
setUploadConfirmation(undefined);
- const { pendingUpload, importFavorites } = confirmation;
+ const { pendingUpload, importFavorites, includePartnerSharedFiles } =
+ confirmation;
if (pendingUpload.type == "existing-collection") {
void commitUploadToExistingCollection(
pendingUpload.collection,
pendingUpload.uploadItemAndPaths,
importFavorites,
+ includePartnerSharedFiles,
);
} else {
void commitUploadToNewCollections(
@@ -1071,6 +1084,7 @@ export const Upload: React.FC<UploadProps> = ({
createHidden: pendingUpload.createHidden,
},
importFavorites,
+ includePartnerSharedFiles,
);
}
};
@@ -1092,6 +1106,16 @@ export const Upload: React.FC<UploadProps> = ({
: undefined,
);
+ const handleIncludePartnerSharedFilesChange = (
+ _event: React.ChangeEvent<HTMLInputElement>,
+ checked: boolean,
+ ) =>
+ setUploadConfirmation((confirmation) =>
+ confirmation
+ ? { ...confirmation, includePartnerSharedFiles: checked }
+ : undefined,
+ );
+
const waitInQueueAndUploadFiles = async (
uploadItemsWithCollection: UploadItemWithCollection[],
collections: Collection[],
@@ -1128,6 +1152,8 @@ export const Upload: React.FC<UploadProps> = ({
opts?.postUploadTargetCollection;
retryImportTakeoutFavorites.current =
opts?.importTakeoutFavorites ?? true;
+ retryIncludePartnerSharedFiles.current =
+ opts?.includePartnerSharedFiles ?? false;
await preUploadAction();
if (
opts?.persistPendingUploads &&
@@ -1150,6 +1176,7 @@ export const Upload: React.FC<UploadProps> = ({
{
skipDuplicateAddToUploadCollection:
!!opts?.postUploadTargetCollection,
+ includePartnerSharedFiles: opts?.includePartnerSharedFiles,
},
);
if (!batchResult.processedAny) closeUploadProgress();
@@ -1192,6 +1219,8 @@ export const Upload: React.FC<UploadProps> = ({
{
skipDuplicateAddToUploadCollection:
!!retrySharedAlbumUploadTarget.current,
+ includePartnerSharedFiles:
+ retryIncludePartnerSharedFiles.current,
},
);
if (!batchResult.processedAny) closeUploadProgress();
@@ -1368,6 +1397,12 @@ export const Upload: React.FC<UploadProps> = ({
uploadConfirmation?.importFavorites ?? true
}
onImportFavoritesChange={handleImportFavoritesChange}
+ includePartnerSharedFiles={
+ uploadConfirmation?.includePartnerSharedFiles ?? true
+ }
+ onIncludePartnerSharedFilesChange={
+ handleIncludePartnerSharedFilesChange
+ }
onConfirm={handleUploadConfirm}
onCancel={cancelPendingUpload}
/>
diff --git a/web/apps/photos/src/components/UploadConfirmationDialog.tsx b/web/apps/photos/src/components/UploadConfirmationDialog.tsx
index 3702d8aa50..84a44f939e 100644
--- a/web/apps/photos/src/components/UploadConfirmationDialog.tsx
+++ b/web/apps/photos/src/components/UploadConfirmationDialog.tsx
@@ -1,8 +1,8 @@
import {
- ArrowLeft02Icon,
Cancel01Icon,
StarIcon,
Tick02Icon,
+ UserMultipleIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import {
@@ -31,6 +31,11 @@ interface UploadConfirmationDialogProps {
event: ChangeEvent<HTMLInputElement>,
checked: boolean,
) => void;
+ includePartnerSharedFiles: boolean;
+ onIncludePartnerSharedFilesChange: (
+ event: ChangeEvent<HTMLInputElement>,
+ checked: boolean,
+ ) => void;
onConfirm: () => void;
onCancel: () => void;
}
@@ -42,6 +47,8 @@ export function UploadConfirmationDialog({
albumCount,
importFavorites,
onImportFavoritesChange,
+ includePartnerSharedFiles,
+ onIncludePartnerSharedFilesChange,
onConfirm,
onCancel,
}: UploadConfirmationDialogProps): ReactElement {
@@ -61,13 +68,6 @@ export function UploadConfirmationDialog({
: "Upload to Ente"}
</Typography>
<Stack direction="row" sx={headerActionsSx}>
- <IconButton
- aria-label="Back"
- onClick={onCancel}
- sx={headerButtonSx}
- >
- <HugeiconsIcon icon={ArrowLeft02Icon} size={24} />
- </IconButton>
<IconButton
aria-label="Close"
onClick={onCancel}
@@ -138,6 +138,35 @@ export function UploadConfirmationDialog({
sx={switchSx}
/>
</Stack>
+ <Stack direction="row" sx={optionSx}>
+ <Box sx={optionIconSx}>
+ <HugeiconsIcon
+ icon={UserMultipleIcon}
+ size={18}
+ />
+ </Box>
+ <Stack sx={optionTextSx}>
+ <Typography sx={bodySx}>
+ Partner shared photos
+ </Typography>
+ <Typography sx={captionSx}>
+ Import photos that were shared by your
+ partner on Google Photos
+ </Typography>
+ </Stack>
+ <EnteSwitch
+ color="accent"
+ checked={includePartnerSharedFiles}
+ onChange={onIncludePartnerSharedFilesChange}
+ slotProps={{
+ input: {
+ "aria-label":
+ "Partner shared photos",
+ },
+ }}
+ sx={switchSx}
+ />
+ </Stack>
</Stack>
)}
</Stack>
@@ -295,14 +324,14 @@ const optionIconSx = {
const optionTextSx = { flex: 1, minWidth: 0, gap: "4px" };
const switchSx = {
- width: 36,
- height: 21,
+ width: 31,
+ height: 18,
flexShrink: 0,
"& .MuiSwitch-switchBase": {
m: "2px",
- "&.Mui-checked": { transform: "translateX(15px)" },
+ "&.Mui-checked": { transform: "translateX(13px)" },
},
- "& .MuiSwitch-thumb": { width: 17, height: 17 },
+ "& .MuiSwitch-thumb": { width: 14, height: 14 },
};
const bodySx = { fontSize: 14, fontWeight: 500, lineHeight: "20px" };
diff --git a/web/apps/photos/src/services/upload-manager.ts b/web/apps/photos/src/services/upload-manager.ts
index 7f4a510bb7..0451f65743 100644
--- a/web/apps/photos/src/services/upload-manager.ts
+++ b/web/apps/photos/src/services/upload-manager.ts
@@ -91,6 +91,7 @@ export interface UploadBatchResult {
interface UploadItemsOptions {
skipDuplicateAddToUploadCollection?: boolean;
+ includePartnerSharedFiles?: boolean;
}
export const successfulFilesFromUploadBatchResult = (
@@ -601,6 +602,7 @@ class UploadManager {
isCFUploadProxyDisabled: shouldDisableCFUploadProxy(),
skipDuplicateAddToUploadCollection:
options?.skipDuplicateAddToUploadCollection,
+ includePartnerSharedFiles: options?.includePartnerSharedFiles,
abortIfCancelled: this.abortIfCancelled.bind(this),
updateUploadProgress:
uiService.updateUploadProgress.bind(uiService),
diff --git a/web/packages/gallery/services/upload/upload-service.ts b/web/packages/gallery/services/upload/upload-service.ts
index 9672a2f45f..2aad3eb0fe 100644
--- a/web/packages/gallery/services/upload/upload-service.ts
+++ b/web/packages/gallery/services/upload/upload-service.ts
@@ -686,6 +686,11 @@ interface UploadContext {
* This is used when the current collection is only an upload staging target.
*/
skipDuplicateAddToUploadCollection?: boolean;
+ /**
+ * If true, media originating from Google Photos partner sharing is
+ * uploaded. Otherwise it is skipped before reading the media file.
+ */
+ includePartnerSharedFiles?: boolean;
/**
* If present, then the upload is happening in the context of the public
* albums app and these are the credentials that should be used for
@@ -717,14 +722,6 @@ interface UploadContext {
updateUploadProgress: (fileLocalID: number, percentage: number) => void;
}
-/**
- * Internal flag: if false (the default), media files whose Google Takeout
- * metadata JSON indicates they originated from Google Photos partner sharing
- * (googlePhotosOrigin.fromPartnerSharing) are skipped during upload, since
- * they cause duplicates when multiple family members import their takeouts.
- */
-const includePartnerSharedFiles = false;
-
/**
* Upload the given {@link UploadableUploadItem}
*
@@ -743,12 +740,14 @@ export const upload = async (
worker: CryptoWorker,
uploadContext: UploadContext,
): Promise<UploadResult> => {
- const { abortIfCancelled, skipDuplicateAddToUploadCollection } =
- uploadContext;
+ const {
+ abortIfCancelled,
+ includePartnerSharedFiles,
+ skipDuplicateAddToUploadCollection,
+ } = uploadContext;
log.info(`Upload ${fileName} | start`);
try {
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!includePartnerSharedFiles) {
const parsedMetadataJSON = matchJSONMetadata(
uploadAsset.pathPrefix,