Skip to content

armgit / ente

Public Imported from GitHub
0

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

add selected files download progress

Abhinavf9c817873ecb
diff --cc apps/photos/src/components/PhotoFrame.tsx
index 7b20fb36ea,a45ea1510c..c54dd8be70
--- a/apps/photos/src/components/PhotoFrame.tsx
+++ b/apps/photos/src/components/PhotoFrame.tsx
@@@ -11,11 -11,7 +11,10 @@@ import AutoSizer from 'react-virtualize
import PhotoViewer from 'components/PhotoViewer';
import { TRASH_SECTION } from 'constants/collection';
import { updateFileMsrcProps, updateFileSrcProps } from 'utils/photoFrame';
-import { SelectedState } from 'types/gallery';
+import {
+ SelectedState,
+ SetFilesDownloadProgressAttributesCreator,
+} from 'types/gallery';
- import { PublicCollectionGalleryContext } from 'utils/publicCollectionGallery';
import { useRouter } from 'next/router';
import { logError } from '@ente/shared/sentry';
import { addLogLine } from '@ente/shared/logging';
diff --cc apps/photos/src/pages/shared-albums/index.tsx
index 3df4ac7474,0efc1451ef..8f99213d77
--- a/apps/photos/src/pages/shared-albums/index.tsx
+++ b/apps/photos/src/pages/shared-albums/index.tsx
@@@ -16,7 -16,13 +16,12 @@@ import
} from 'services/publicCollectionService';
import { Collection } from 'types/collection';
import { EnteFile } from 'types/file';
- import { mergeMetadata, sortFiles } from 'utils/file';
+ import {
- downloadFile,
- downloadFiles,
++ downloadSelectedFiles,
+ getSelectedFiles,
+ mergeMetadata,
+ sortFiles,
+ } from 'utils/file';
import { AppContext } from 'pages/_app';
import { PublicCollectionGalleryContext } from 'utils/publicCollectionGallery';
import { CustomError, parseSharingErrorCodes } from '@ente/shared/error';
@@@ -52,11 -58,7 +57,12 @@@ import UploadButton from 'components/Up
import bs58 from 'bs58';
import AddPhotoAlternateOutlined from '@mui/icons-material/AddPhotoAlternateOutlined';
import ComlinkCryptoWorker from '@ente/shared/crypto';
-import { SelectedState, UploadTypeSelectorIntent } from 'types/gallery';
+import {
++ SelectedState,
+ SetFilesDownloadProgressAttributes,
+ SetFilesDownloadProgressAttributesCreator,
+ UploadTypeSelectorIntent,
+} from 'types/gallery';
import FileDownloadOutlinedIcon from '@mui/icons-material/FileDownloadOutlined';
import MoreHoriz from '@mui/icons-material/MoreHoriz';
import OverflowMenu from '@ente/shared/components/OverflowMenu/menu';
@@@ -64,11 -66,7 +70,12 @@@ import { OverflowMenuOption } from '@en
import { ENTE_WEBSITE_LINK } from '@ente/shared/constants/urls';
import { APPS } from '@ente/shared/apps/constants';
import downloadManager from 'services/download';
+import {
+ FilesDownloadProgress,
+ FilesDownloadProgressAttributes,
+} from 'components/FilesDownloadProgress';
+import { downloadCollectionFiles, isHiddenCollection } from 'utils/collection';
+ import SelectedFileOptions from 'components/pages/sharedAlbum/SelectedFileOptions';
export default function PublicCollectionGallery() {
const token = useRef<string>(null);
@@@ -95,6 -93,12 +102,11 @@@
const [uploadTypeSelectorView, setUploadTypeSelectorView] = useState(false);
const [blockingLoad, setBlockingLoad] = useState(false);
const [shouldDisableDropzone, setShouldDisableDropzone] = useState(false);
-
+ const [selected, setSelected] = useState<SelectedState>({
+ ownCount: 0,
+ count: 0,
+ collectionID: 0,
+ });
const {
getRootProps: getDragAndDropRootProps,
@@@ -495,6 -454,22 +507,29 @@@
}
}
+ const downloadFilesHelper = async () => {
+ try {
+ const selectedFiles = getSelectedFiles(selected, publicFiles);
- await downloadFiles(selectedFiles);
++ const setFilesDownloadProgressAttributes =
++ setFilesDownloadProgressAttributesCreator(
++ `${selectedFiles.length} ${t('FILES')}`
++ );
++ await downloadSelectedFiles(
++ selectedFiles,
++ setFilesDownloadProgressAttributes
++ );
+ } catch (e) {
+ logError(e, 'failed to download selected files');
+ }
+ };
+
+ const clearSelection = () => {
+ if (!selected?.count) {
+ return;
+ }
+ setSelected({ ownCount: 0, count: 0, collectionID: 0 });
+ };
+
return (
<PublicCollectionGalleryContext.Provider
value={{
@@@ -555,10 -527,14 +590,18 @@@
UploadTypeSelectorIntent.collectPhotos
}
/>
+ <FilesDownloadProgress
+ attributesList={filesDownloadProgressAttributesList}
+ setAttributesList={setFilesDownloadProgressAttributesList}
+ />
+ {selected.count > 0 && (
+ <SelectedFileOptions
+ downloadFilesHelper={downloadFilesHelper}
+ clearSelection={clearSelection}
+ count={selected.count}
+ ownCount={selected.ownCount}
+ />
+ )}
</FullScreenDropZone>
</PublicCollectionGalleryContext.Provider>
);
diff --cc apps/photos/src/utils/file/index.ts
index 1934f17077,3cf6ed39d4..13dd0474d0
--- a/apps/photos/src/utils/file/index.ts
+++ b/apps/photos/src/utils/file/index.ts
@@@ -56,6 -52,6 +56,7 @@@ import { getFileExportPath, getUniqueFi
import imageProcessor from 'services/imageProcessor';
import ElectronAPIs from '@ente/shared/electron';
import { downloadUsingAnchor } from '@ente/shared/utils';
++import { t } from 'i18next';
const WAIT_TIME_IMAGE_CONVERSION = 30 * 1000;
@@@ -973,17 -881,9 +974,17 @@@ export const handleFileOps = async
case FILE_OPS_TYPE.HIDE:
await hideFilesHelper(files, setHiddenFileIds);
break;
- case FILE_OPS_TYPE.DOWNLOAD:
- await downloadFiles(files);
+ case FILE_OPS_TYPE.DOWNLOAD: {
+ const setSelectedFileDownloadProgressAttributes =
+ setFilesDownloadProgressAttributesCreator(
- `${files.length} files`
++ `${files.length} ${t('FILES')}`
+ );
+ await downloadSelectedFiles(
+ files,
+ setSelectedFileDownloadProgressAttributes
+ );
break;
+ }
case FILE_OPS_TYPE.FIX_TIME:
fixTimeHelper(files, setFixCreationTimeAttributes);
break;