only group actual collection

This commit is contained in:
Abhinav 2022-08-27 15:28:12 +05:30
parent 45aee68c36
commit 617a607878

View file

@ -25,7 +25,7 @@ import HEICConverter from 'services/heicConverter/heicConverterService';
import ffmpegService from 'services/ffmpeg/ffmpegService'; import ffmpegService from 'services/ffmpeg/ffmpegService';
import { NEW_FILE_MAGIC_METADATA, VISIBILITY_STATE } from 'types/magicMetadata'; import { NEW_FILE_MAGIC_METADATA, VISIBILITY_STATE } from 'types/magicMetadata';
import { IsArchived, updateMagicMetadataProps } from 'utils/magicMetadata'; import { IsArchived, updateMagicMetadataProps } from 'utils/magicMetadata';
import { ARCHIVE_SECTION, TRASH_SECTION } from 'constants/collection';
import { addLogLine } from 'utils/logging'; import { addLogLine } from 'utils/logging';
import { makeHumanReadableStorage } from 'utils/billing'; import { makeHumanReadableStorage } from 'utils/billing';
export function downloadAsFile(filename: string, content: string) { export function downloadAsFile(filename: string, content: string) {
@ -133,21 +133,13 @@ function downloadUsingAnchor(link: string, name: string) {
} }
export function sortFilesIntoCollections(files: EnteFile[]) { export function sortFilesIntoCollections(files: EnteFile[]) {
const collectionWiseFiles = new Map<number, EnteFile[]>([ const collectionWiseFiles = new Map<number, EnteFile[]>();
[ARCHIVE_SECTION, []],
[TRASH_SECTION, []],
]);
for (const file of files) { for (const file of files) {
if (!collectionWiseFiles.has(file.collectionID)) { if (!collectionWiseFiles.has(file.collectionID)) {
collectionWiseFiles.set(file.collectionID, []); collectionWiseFiles.set(file.collectionID, []);
} }
if (file.isTrashed) { if (!file.isTrashed) {
collectionWiseFiles.get(TRASH_SECTION).push(file);
} else {
collectionWiseFiles.get(file.collectionID).push(file); collectionWiseFiles.get(file.collectionID).push(file);
if (IsArchived(file)) {
collectionWiseFiles.get(ARCHIVE_SECTION).push(file);
}
} }
} }
return collectionWiseFiles; return collectionWiseFiles;