This commit is contained in:
Manav Rathi
2024-10-05 12:12:39 +05:30
parent b1f603d463
commit b00009aaab
3 changed files with 22 additions and 30 deletions

View File

@@ -6,9 +6,9 @@ import {
LargeTileTextOverlay,
} from "@/new/photos/components/ItemCards";
import {
canAddToCollection,
canMoveToCollection,
CollectionSummaryOrder,
isAddToAllowedCollection,
isMoveToAllowedCollection,
type CollectionSummaries,
type CollectionSummary,
} from "@/new/photos/services/collection/ui";
@@ -88,23 +88,21 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
} else if (
attributes.intent === CollectionSelectorIntent.add
) {
return isAddToAllowedCollection(type);
return canAddToCollection(type);
} else if (
attributes.intent === CollectionSelectorIntent.upload
) {
return (
isMoveToAllowedCollection(type) ||
type == "uncategorized"
canMoveToCollection(type) || type == "uncategorized"
);
} else if (
attributes.intent === CollectionSelectorIntent.restore
) {
return (
isMoveToAllowedCollection(type) ||
type == "uncategorized"
canMoveToCollection(type) || type == "uncategorized"
);
} else {
return isMoveToAllowedCollection(type);
return canMoveToCollection(type);
}
})
.sort((a, b) => {

View File

@@ -1,9 +1,4 @@
import type { Collection } from "@/media/collection";
import {
hasNonSystemCollections,
isSystemCollection,
shouldBeShownOnCollectionBar,
} from "@/new/photos/services/collection/ui";
import {
GalleryBarImpl,
type GalleryBarImplProps,
@@ -11,6 +6,9 @@ import {
import { PeopleHeader } from "@/new/photos/components/Gallery/PeopleHeader";
import {
collectionsSortBy,
hasNonSystemCollections,
isSystemCollection,
shouldShowOnCollectionBar,
type CollectionsSortBy,
type CollectionSummaries,
} from "@/new/photos/services/collection/ui";
@@ -212,7 +210,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
onChangeCollectionsSortBy={setCollectionsSortBy}
onShowAllCollections={() => setOpenAllCollectionDialog(true)}
collectionSummaries={sortedCollectionSummaries.filter((x) =>
shouldBeShownOnCollectionBar(x.type),
shouldShowOnCollectionBar(x.type),
)}
/>

View File

@@ -77,7 +77,7 @@ export const CollectionSummaryOrder = new Map<CollectionSummaryType, number>([
["defaultHidden", 7],
]);
const SYSTEM_COLLECTION_TYPES = new Set<CollectionSummaryType>([
const systemCSTypes = new Set<CollectionSummaryType>([
"all",
"archive",
"trash",
@@ -86,7 +86,7 @@ const SYSTEM_COLLECTION_TYPES = new Set<CollectionSummaryType>([
"defaultHidden",
]);
const ADD_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
const addToDisabledCSTypes = new Set<CollectionSummaryType>([
"all",
"archive",
"incomingShareViewer",
@@ -96,7 +96,7 @@ const ADD_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
"hiddenItems",
]);
const MOVE_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
const moveToDisabledCSTypes = new Set<CollectionSummaryType>([
"all",
"archive",
"incomingShareViewer",
@@ -107,7 +107,7 @@ const MOVE_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
"hiddenItems",
]);
const HIDE_FROM_COLLECTION_BAR_TYPES = new Set<CollectionSummaryType>([
const hideFromCollectionBarCSTypes = new Set<CollectionSummaryType>([
"trash",
"archive",
"uncategorized",
@@ -123,18 +123,14 @@ export const hasNonSystemCollections = (
return false;
};
export const isMoveToAllowedCollection = (type: CollectionSummaryType) => {
return !MOVE_TO_NOT_ALLOWED_COLLECTION.has(type);
};
export const canMoveToCollection = (type: CollectionSummaryType) =>
!moveToDisabledCSTypes.has(type);
export const isAddToAllowedCollection = (type: CollectionSummaryType) => {
return !ADD_TO_NOT_ALLOWED_COLLECTION.has(type);
};
export const canAddToCollection = (type: CollectionSummaryType) =>
!addToDisabledCSTypes.has(type);
export const isSystemCollection = (type: CollectionSummaryType) => {
return SYSTEM_COLLECTION_TYPES.has(type);
};
export const isSystemCollection = (type: CollectionSummaryType) =>
systemCSTypes.has(type);
export const shouldBeShownOnCollectionBar = (type: CollectionSummaryType) => {
return !HIDE_FROM_COLLECTION_BAR_TYPES.has(type);
};
export const shouldShowOnCollectionBar = (type: CollectionSummaryType) =>
!hideFromCollectionBarCSTypes.has(type);