make hidden collections and files unsearchable and add better isValidReplacementCollection check
This commit is contained in:
parent
923bc858e4
commit
0b66a6685a
|
@ -44,7 +44,7 @@ import PhotoFrame from 'components/PhotoFrame';
|
|||
import {
|
||||
changeFilesVisibility,
|
||||
downloadFiles,
|
||||
getNonTrashedFiles,
|
||||
getSearchableFiles,
|
||||
getSelectedFiles,
|
||||
mergeMetadata,
|
||||
sortFiles,
|
||||
|
@ -77,6 +77,7 @@ import {
|
|||
getSelectedCollection,
|
||||
getArchivedCollections,
|
||||
hasNonSystemCollections,
|
||||
getSearchableCollections,
|
||||
} from 'utils/collection';
|
||||
import { logError } from 'utils/sentry';
|
||||
import {
|
||||
|
@ -716,8 +717,8 @@ export default function Gallery() {
|
|||
setIsInSearchMode={setIsInSearchMode}
|
||||
openUploader={openUploader}
|
||||
isInSearchMode={isInSearchMode}
|
||||
collections={collections}
|
||||
files={getNonTrashedFiles(files)}
|
||||
collections={getSearchableCollections(collections)}
|
||||
files={getSearchableFiles(files)}
|
||||
setActiveCollection={setActiveCollection}
|
||||
updateSearch={updateSearch}
|
||||
/>
|
||||
|
|
|
@ -55,6 +55,7 @@ import {
|
|||
isSharedOnlyViaLink,
|
||||
isValidMoveTarget,
|
||||
isCollectionHidden,
|
||||
isValidReplacementCollection,
|
||||
} from 'utils/collection';
|
||||
import ComlinkCryptoWorker from 'utils/comlink/ComlinkCryptoWorker';
|
||||
import { getLocalFiles } from './fileService';
|
||||
|
@ -313,8 +314,16 @@ export const createCollection = async (
|
|||
if (!existingCollections) {
|
||||
existingCollections = await syncCollections();
|
||||
}
|
||||
const user: User = getData(LS_KEYS.USER);
|
||||
for (const collection of existingCollections) {
|
||||
if (collection.name === collectionName) {
|
||||
if (
|
||||
isValidReplacementCollection(
|
||||
collection,
|
||||
user,
|
||||
collectionName,
|
||||
type
|
||||
)
|
||||
) {
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
} from 'types/collection';
|
||||
import {
|
||||
CollectionSummaryType,
|
||||
CollectionType,
|
||||
HIDE_FROM_COLLECTION_BAR_TYPES,
|
||||
OPTIONS_NOT_HAVING_COLLECTION_TYPES,
|
||||
SYSTEM_COLLECTION_TYPES,
|
||||
|
@ -257,6 +258,21 @@ export function isValidMoveTarget(
|
|||
);
|
||||
}
|
||||
|
||||
export function isValidReplacementCollection(
|
||||
collection: Collection,
|
||||
user: User,
|
||||
wantedCollectionName: string,
|
||||
wantedCollectionType: CollectionType
|
||||
) {
|
||||
return (
|
||||
collection.name !== wantedCollectionName &&
|
||||
collection.type === wantedCollectionType &&
|
||||
!isCollectionHidden(collection) &&
|
||||
!isQuickLinkCollection(collection) &&
|
||||
!isIncomingShare(collection, user)
|
||||
);
|
||||
}
|
||||
|
||||
export function getCollectionNameMap(
|
||||
collections: Collection[]
|
||||
): Map<number, string> {
|
||||
|
@ -282,3 +298,9 @@ export function getNonEmptyPersonalCollections(
|
|||
);
|
||||
return personalCollections;
|
||||
}
|
||||
|
||||
export function getSearchableCollections(
|
||||
collections: Collection[]
|
||||
): Collection[] {
|
||||
return collections.filter((collection) => !isCollectionHidden(collection));
|
||||
}
|
||||
|
|
|
@ -471,9 +471,13 @@ export function getUniqueFiles(files: EnteFile[]) {
|
|||
}
|
||||
});
|
||||
}
|
||||
export function getNonTrashedFiles(files: EnteFile[]) {
|
||||
export function getSearchableFiles(files: EnteFile[]) {
|
||||
return files.filter(
|
||||
(file) => typeof file.isTrashed === 'undefined' || !file.isTrashed
|
||||
(file) =>
|
||||
typeof file.isTrashed === 'undefined' ||
|
||||
!file.isTrashed ||
|
||||
typeof file.isHidden === 'undefined' ||
|
||||
!file.isHidden
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue