restructure and rename
This commit is contained in:
parent
680b796e6c
commit
1cc48655c8
|
@ -10,7 +10,11 @@ import HTTPService from './HTTPService';
|
|||
import { EnteFile } from 'types/file';
|
||||
import { logError } from 'utils/sentry';
|
||||
import { CustomError } from 'utils/error';
|
||||
import { isSharedFile, sortFiles, sortFilesIntoCollections } from 'utils/file';
|
||||
import {
|
||||
isSharedFile,
|
||||
sortFiles,
|
||||
groupFilesIntoCollections as groupFilesBasedOnCollectionID,
|
||||
} from 'utils/file';
|
||||
import {
|
||||
Collection,
|
||||
CollectionLatestFiles,
|
||||
|
@ -828,9 +832,9 @@ function getCollectionsFileCount(
|
|||
files: EnteFile[],
|
||||
archivedCollections: Set<number>
|
||||
): CollectionFilesCount {
|
||||
const collectionWiseFiles = sortFilesIntoCollections(files);
|
||||
const collectionIDToFileMap = groupFilesBasedOnCollectionID(files);
|
||||
const collectionFilesCount = new Map<number, number>();
|
||||
for (const [id, files] of collectionWiseFiles) {
|
||||
for (const [id, files] of collectionIDToFileMap) {
|
||||
collectionFilesCount.set(id, files.length);
|
||||
}
|
||||
const user: User = getData(LS_KEYS.USER);
|
||||
|
@ -838,16 +842,17 @@ function getCollectionsFileCount(
|
|||
const uniqueArchivedFileIDs = new Set<number>();
|
||||
const uniqueAllSectionFileIDs = new Set<number>();
|
||||
for (const file of files) {
|
||||
if (isSharedFile(user, file)) {
|
||||
continue;
|
||||
}
|
||||
if (file.isTrashed) {
|
||||
uniqueTrashedFileIDs.add(file.id);
|
||||
} else if (!isSharedFile(user, file)) {
|
||||
if (IsArchived(file)) {
|
||||
} else if (IsArchived(file)) {
|
||||
uniqueArchivedFileIDs.add(file.id);
|
||||
} else if (!archivedCollections.has(file.collectionID)) {
|
||||
uniqueAllSectionFileIDs.add(file.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
collectionFilesCount.set(TRASH_SECTION, uniqueTrashedFileIDs.size);
|
||||
collectionFilesCount.set(ARCHIVE_SECTION, uniqueArchivedFileIDs.size);
|
||||
collectionFilesCount.set(ALL_SECTION, uniqueAllSectionFileIDs.size);
|
||||
|
|
|
@ -2,7 +2,7 @@ import { getLocalFiles, setLocalFiles } from '../fileService';
|
|||
import { SetFiles } from 'types/gallery';
|
||||
import { getDedicatedCryptoWorker } from 'utils/crypto';
|
||||
import {
|
||||
sortFilesIntoCollections,
|
||||
groupFilesIntoCollections,
|
||||
sortFiles,
|
||||
preservePhotoswipeProps,
|
||||
decryptFile,
|
||||
|
@ -74,7 +74,7 @@ class UploadManager {
|
|||
private async init(collections: Collection[]) {
|
||||
this.resetState();
|
||||
this.existingFiles = await getLocalFiles();
|
||||
this.existingFilesCollectionWise = sortFilesIntoCollections(
|
||||
this.existingFilesCollectionWise = groupFilesIntoCollections(
|
||||
this.existingFiles
|
||||
);
|
||||
this.collections = new Map(
|
||||
|
|
|
@ -132,7 +132,7 @@ function downloadUsingAnchor(link: string, name: string) {
|
|||
a.remove();
|
||||
}
|
||||
|
||||
export function sortFilesIntoCollections(files: EnteFile[]) {
|
||||
export function groupFilesIntoCollections(files: EnteFile[]) {
|
||||
const collectionWiseFiles = new Map<number, EnteFile[]>();
|
||||
for (const file of files) {
|
||||
if (!collectionWiseFiles.has(file.collectionID)) {
|
||||
|
|
Loading…
Reference in a new issue