fix showing/hidding of collection in different context
This commit is contained in:
parent
b44bfe8a8e
commit
4e2c9ca59a
|
@ -5,8 +5,7 @@ import CollectionOptions from 'components/Collections/CollectionOptions';
|
|||
import { SetCollectionNamerAttributes } from 'components/Collections/CollectionNamer';
|
||||
import { SpaceBetweenFlex } from 'components/Container';
|
||||
import { CollectionInfoBarWrapper } from './styledComponents';
|
||||
import { isSystemCollection } from 'utils/collection';
|
||||
import { TRASH_SECTION } from 'constants/collection';
|
||||
import { isOptionsHavingCollection } from 'utils/collection';
|
||||
|
||||
interface Iprops {
|
||||
activeCollection: Collection;
|
||||
|
@ -32,13 +31,13 @@ export default function CollectionInfoWithOptions({
|
|||
return <></>;
|
||||
}
|
||||
|
||||
const { name, type, fileCount, id } = collectionSummary;
|
||||
const { name, type, fileCount } = collectionSummary;
|
||||
|
||||
return (
|
||||
<CollectionInfoBarWrapper>
|
||||
<SpaceBetweenFlex>
|
||||
<CollectionInfo name={name} fileCount={fileCount} />
|
||||
{(!isSystemCollection(type) || id === TRASH_SECTION) && (
|
||||
{isOptionsHavingCollection(type) && (
|
||||
<CollectionOptions {...props} />
|
||||
)}
|
||||
</SpaceBetweenFlex>
|
||||
|
|
|
@ -15,6 +15,7 @@ import useWindowSize from 'hooks/useWindowSize';
|
|||
import LinkButton from 'components/pages/gallery/LinkButton';
|
||||
import { SpaceBetweenFlex } from 'components/Container';
|
||||
import { sortCollectionSummaries } from 'services/collectionService';
|
||||
import { shouldBeShownOnCollectionBar } from 'utils/collection';
|
||||
|
||||
interface IProps {
|
||||
activeCollection?: number;
|
||||
|
@ -34,8 +35,8 @@ export default function CollectionListBar(props: IProps) {
|
|||
const sortedCollectionSummary = useMemo(
|
||||
() =>
|
||||
sortCollectionSummaries(
|
||||
[...collectionSummaries.values()].filter(
|
||||
(c) => c.fileCount > 0
|
||||
[...collectionSummaries.values()].filter((c) =>
|
||||
shouldBeShownOnCollectionBar(c.type)
|
||||
),
|
||||
COLLECTION_SORT_BY.UPDATION_TIME_DESCENDING
|
||||
),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useContext, useEffect, useMemo } from 'react';
|
||||
import { Collection, CollectionSummaries } from 'types/collection';
|
||||
import DialogTitleWithCloseButton from 'components/DialogBox/TitleWithCloseButton';
|
||||
import { isSystemCollection } from 'utils/collection';
|
||||
import { isUploadAllowedCollection } from 'utils/collection';
|
||||
import { AppContext } from 'pages/_app';
|
||||
import { AllCollectionDialog } from 'components/Collections/AllCollections/dialog';
|
||||
import { DialogContent } from '@mui/material';
|
||||
|
@ -35,7 +35,8 @@ function CollectionSelector({
|
|||
...collectionSummaries.values(),
|
||||
]?.filter(
|
||||
({ type, id }) =>
|
||||
id !== attributes?.fromCollection && !isSystemCollection(type)
|
||||
id !== attributes?.fromCollection &&
|
||||
!isUploadAllowedCollection(type)
|
||||
);
|
||||
return personalCollectionsOtherThanFrom;
|
||||
}, [collectionSummaries, attributes]);
|
||||
|
|
|
@ -37,5 +37,21 @@ export const SYSTEM_COLLECTION_TYPES = new Set([
|
|||
CollectionType.all,
|
||||
CollectionType.archive,
|
||||
CollectionType.trash,
|
||||
CollectionType.shared,
|
||||
]);
|
||||
|
||||
export const UPLOAD_ALLOWED_COLLECTION_TYPES = new Set([
|
||||
CollectionType.album,
|
||||
CollectionType.folder,
|
||||
CollectionType.favorites,
|
||||
]);
|
||||
|
||||
export const OPTIONS_HAVING_COLLECTION_TYPES = new Set([
|
||||
CollectionType.folder,
|
||||
CollectionType.album,
|
||||
CollectionType.trash,
|
||||
]);
|
||||
|
||||
export const HIDE_FROM_COLLECTION_BAR_TYPES = new Set([
|
||||
CollectionType.trash,
|
||||
CollectionType.archive,
|
||||
]);
|
||||
|
|
|
@ -19,7 +19,13 @@ import {
|
|||
CollectionMagicMetadataProps,
|
||||
CollectionSummaries,
|
||||
} from 'types/collection';
|
||||
import { CollectionType, SYSTEM_COLLECTION_TYPES } from 'constants/collection';
|
||||
import {
|
||||
CollectionType,
|
||||
HIDE_FROM_COLLECTION_BAR_TYPES,
|
||||
OPTIONS_HAVING_COLLECTION_TYPES,
|
||||
SYSTEM_COLLECTION_TYPES,
|
||||
UPLOAD_ALLOWED_COLLECTION_TYPES,
|
||||
} from 'constants/collection';
|
||||
import { getAlbumSiteHost } from 'constants/pages';
|
||||
import { getUnixTimeInMicroSecondsWithDelta } from 'utils/time';
|
||||
import {
|
||||
|
@ -202,6 +208,18 @@ export const hasNonEmptyCollections = (
|
|||
return collectionSummaries?.size <= 3;
|
||||
};
|
||||
|
||||
export const isUploadAllowedCollection = (type: CollectionType) => {
|
||||
return UPLOAD_ALLOWED_COLLECTION_TYPES.has(type);
|
||||
};
|
||||
|
||||
export const isSystemCollection = (type: CollectionType) => {
|
||||
return SYSTEM_COLLECTION_TYPES.has(type);
|
||||
};
|
||||
|
||||
export const isOptionsHavingCollection = (type: CollectionType) => {
|
||||
return OPTIONS_HAVING_COLLECTION_TYPES.has(type);
|
||||
};
|
||||
|
||||
export const shouldBeShownOnCollectionBar = (type: CollectionType) => {
|
||||
return !HIDE_FROM_COLLECTION_BAR_TYPES.has(type);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue