diff --git a/src/constants/collection/index.ts b/src/constants/collection/index.ts index 3b95173a1..6bce182e1 100644 --- a/src/constants/collection/index.ts +++ b/src/constants/collection/index.ts @@ -6,12 +6,18 @@ export enum CollectionType { folder = 'folder', favorites = 'favorites', album = 'album', +} + +export enum CollectionSummaryType { + folder = 'folder', + favorites = 'favorites', + album = 'album', archive = 'archive', trash = 'trash', all = 'all', shared = 'shared', + archived = 'archived', } - export enum COLLECTION_SORT_BY { NAME, CREATION_TIME_ASCENDING, @@ -24,34 +30,34 @@ export const COLLECTION_SHARE_DEFAULT_VALID_DURATION = export const COLLECTION_SHARE_DEFAULT_DEVICE_LIMIT = 4; export const COLLECTION_SORT_ORDER = new Map([ - [CollectionType.all, 0], - [CollectionType.favorites, 1], - [CollectionType.album, 2], - [CollectionType.folder, 2], - [CollectionType.shared, 2], - [CollectionType.archive, 3], - [CollectionType.trash, 4], + [CollectionSummaryType.all, 0], + [CollectionSummaryType.favorites, 1], + [CollectionSummaryType.album, 2], + [CollectionSummaryType.folder, 2], + [CollectionSummaryType.shared, 2], + [CollectionSummaryType.archive, 3], + [CollectionSummaryType.trash, 4], ]); export const SYSTEM_COLLECTION_TYPES = new Set([ - CollectionType.all, - CollectionType.archive, - CollectionType.trash, + CollectionSummaryType.all, + CollectionSummaryType.archive, + CollectionSummaryType.trash, ]); export const UPLOAD_ALLOWED_COLLECTION_TYPES = new Set([ - CollectionType.album, - CollectionType.folder, - CollectionType.favorites, + CollectionSummaryType.album, + CollectionSummaryType.folder, + CollectionSummaryType.favorites, ]); export const OPTIONS_HAVING_COLLECTION_TYPES = new Set([ - CollectionType.folder, - CollectionType.album, - CollectionType.trash, + CollectionSummaryType.folder, + CollectionSummaryType.album, + CollectionSummaryType.trash, ]); export const HIDE_FROM_COLLECTION_BAR_TYPES = new Set([ - CollectionType.trash, - CollectionType.archive, + CollectionSummaryType.trash, + CollectionSummaryType.archive, ]); diff --git a/src/services/collectionService.ts b/src/services/collectionService.ts index 8c5929014..08962ddb5 100644 --- a/src/services/collectionService.ts +++ b/src/services/collectionService.ts @@ -32,6 +32,7 @@ import { TRASH_SECTION, COLLECTION_SORT_ORDER, ALL_SECTION, + CollectionSummaryType, } from 'constants/collection'; import { UpdateMagicMetadataRequest } from 'types/magicMetadata'; import { EncryptionResult } from 'types/upload'; @@ -786,8 +787,10 @@ export function getCollectionSummaries( updationTime: collection.updationTime, type: collection.owner.id !== user.id - ? CollectionType.shared - : collection.type, + ? CollectionSummaryType.shared + : IsArchived(collection) + ? CollectionSummaryType.archived + : CollectionSummaryType[collection.type], }); } } @@ -853,7 +856,7 @@ function getAllCollectionSummaries( return { id: ALL_SECTION, name: constants.ALL_SECTION_NAME, - type: CollectionType.all, + type: CollectionSummaryType.all, latestFile: collectionsLatestFile.get(ALL_SECTION), fileCount: allSectionFileCount, updationTime: collectionsLatestFile.get(ALL_SECTION)?.updationTime, @@ -867,7 +870,7 @@ function getArchivedCollectionSummaries( return { id: ARCHIVE_SECTION, name: constants.ARCHIVE_SECTION_NAME, - type: CollectionType.archive, + type: CollectionSummaryType.archive, latestFile: collectionsLatestFile.get(ARCHIVE_SECTION), fileCount: collectionFilesCount.get(ARCHIVE_SECTION) ?? 0, updationTime: collectionsLatestFile.get(ARCHIVE_SECTION)?.updationTime, @@ -881,7 +884,7 @@ function getTrashedCollectionSummaries( return { id: TRASH_SECTION, name: constants.TRASH, - type: CollectionType.trash, + type: CollectionSummaryType.trash, latestFile: collectionsLatestFile.get(TRASH_SECTION), fileCount: collectionFilesCount.get(TRASH_SECTION) ?? 0, updationTime: collectionsLatestFile.get(TRASH_SECTION)?.updationTime, diff --git a/src/types/collection/index.ts b/src/types/collection/index.ts index 5860a4641..73925bbfe 100644 --- a/src/types/collection/index.ts +++ b/src/types/collection/index.ts @@ -1,6 +1,6 @@ import { User } from 'types/user'; import { EnteFile } from 'types/file'; -import { CollectionType } from 'constants/collection'; +import { CollectionSummaryType, CollectionType } from 'constants/collection'; import { MagicMetadataCore, VISIBILITY_STATE } from 'types/magicMetadata'; export interface Collection { @@ -91,7 +91,7 @@ export interface CollectionMagicMetadata export interface CollectionSummary { id: number; name: string; - type: CollectionType; + type: CollectionSummaryType; latestFile: EnteFile; fileCount: number; updationTime: number; @@ -99,10 +99,3 @@ export interface CollectionSummary { export type CollectionSummaries = Map; export type CollectionFilesCount = Map; - -export interface CollectionInfo { - id: number; - name: string; - fileCount: number; - type: CollectionType; -} diff --git a/src/utils/collection/index.ts b/src/utils/collection/index.ts index 05cc7a94a..0793c5da1 100644 --- a/src/utils/collection/index.ts +++ b/src/utils/collection/index.ts @@ -20,6 +20,7 @@ import { CollectionSummaries, } from 'types/collection'; import { + CollectionSummaryType, CollectionType, HIDE_FROM_COLLECTION_BAR_TYPES, OPTIONS_HAVING_COLLECTION_TYPES, @@ -208,18 +209,18 @@ export const hasNonEmptyCollections = ( return collectionSummaries?.size <= 3; }; -export const isUploadAllowedCollection = (type: CollectionType) => { +export const isUploadAllowedCollection = (type: CollectionSummaryType) => { return UPLOAD_ALLOWED_COLLECTION_TYPES.has(type); }; -export const isSystemCollection = (type: CollectionType) => { +export const isSystemCollection = (type: CollectionSummaryType) => { return SYSTEM_COLLECTION_TYPES.has(type); }; -export const isOptionsHavingCollection = (type: CollectionType) => { +export const isOptionsHavingCollection = (type: CollectionSummaryType) => { return OPTIONS_HAVING_COLLECTION_TYPES.has(type); }; -export const shouldBeShownOnCollectionBar = (type: CollectionType) => { +export const shouldBeShownOnCollectionBar = (type: CollectionSummaryType) => { return !HIDE_FROM_COLLECTION_BAR_TYPES.has(type); };