filter non user and trashed files from existing files
This commit is contained in:
parent
412e035e85
commit
8f7714b07f
|
@ -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
|
||||||
);
|
);
|
||||||
|
|
|
@ -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);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue