filter non user and trashed files from existing files

This commit is contained in:
Abhinav 2022-09-01 13:43:11 +05:30
parent 412e035e85
commit 8f7714b07f
2 changed files with 10 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import {
sortFiles, sortFiles,
preservePhotoswipeProps, preservePhotoswipeProps,
decryptFile, decryptFile,
getUserOwnedNonTrashedFiles,
} from 'utils/file'; } from 'utils/file';
import { logError } from 'utils/sentry'; import { logError } from 'utils/sentry';
import { getMetadataJSONMapKey, parseMetadataJSON } from './metadataService'; import { getMetadataJSONMapKey, parseMetadataJSON } from './metadataService';
@ -82,7 +83,7 @@ class UploadManager {
} }
async updateExistingFilesAndCollections(collections: Collection[]) { async updateExistingFilesAndCollections(collections: Collection[]) {
this.existingFiles = await getLocalFiles(); this.existingFiles = getUserOwnedNonTrashedFiles(await getLocalFiles());
this.collectionToExistingFilesMap = groupFilesBasedOnCollectionID( this.collectionToExistingFilesMap = groupFilesBasedOnCollectionID(
this.existingFiles this.existingFiles
); );

View file

@ -508,3 +508,11 @@ export const createTypedObjectURL = async (blob: Blob, fileName: string) => {
const type = await getFileType(new File([blob], fileName)); const type = await getFileType(new File([blob], fileName));
return URL.createObjectURL(new Blob([blob], { type: type.mimeType })); return URL.createObjectURL(new Blob([blob], { type: type.mimeType }));
}; };
export const getUserOwnedNonTrashedFiles = (files: EnteFile[]) => {
const user: User = getData(LS_KEYS.USER);
if (!user?.id) {
throw Error('user missing');
}
return files.filter((file) => file.isTrashed || file.ownerID !== user.id);
};