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