From 2bd45883ce0dadcbf0d4b23e3d9fad1d88f5b769 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 9 Sep 2024 16:40:39 +0530 Subject: [PATCH] Inline --- .../Collections/AllCollections/index.tsx | 2 +- .../Collections/CollectionInfoWithOptions.tsx | 2 +- .../CollectionListBar/CollectionCard.tsx | 2 +- .../Collections/CollectionListBar/index.tsx | 2 +- .../Collections/CollectionListSortBy.tsx | 2 +- .../QuickOptions/DownloadQuickOption.tsx | 2 +- .../QuickOptions/ShareQuickOption.tsx | 2 +- .../CollectionOptions/QuickOptions/index.tsx | 2 +- .../Collections/CollectionOptions/index.tsx | 8 +-- .../Collections/CollectionSelector/index.tsx | 8 +-- .../Collections/CollectionShare/index.tsx | 2 +- .../CollectionShare/sharingDetails.tsx | 2 +- .../src/components/Collections/index.tsx | 3 +- web/apps/photos/src/components/PhotoFrame.tsx | 2 +- .../photos/src/components/Sidebar/index.tsx | 10 ++-- .../components/pages/gallery/PreviewCard.tsx | 2 +- .../pages/gallery/SelectedFileOptions.tsx | 12 ++-- web/apps/photos/src/constants/collection.ts | 54 ----------------- web/apps/photos/src/pages/deduplicate.tsx | 2 +- web/apps/photos/src/pages/gallery.tsx | 12 ++-- web/apps/photos/src/pages/shared-albums.tsx | 7 ++- .../photos/src/services/collectionService.ts | 20 +++---- web/apps/photos/src/types/collection/index.ts | 2 +- web/apps/photos/src/utils/collection/index.ts | 59 +++++++++++++++++-- 24 files changed, 106 insertions(+), 115 deletions(-) diff --git a/web/apps/photos/src/components/Collections/AllCollections/index.tsx b/web/apps/photos/src/components/Collections/AllCollections/index.tsx index 586ebd1680..4fc96e9ecd 100644 --- a/web/apps/photos/src/components/Collections/AllCollections/index.tsx +++ b/web/apps/photos/src/components/Collections/AllCollections/index.tsx @@ -3,8 +3,8 @@ import { AllCollectionDialog, Transition, } from "components/Collections/AllCollections/dialog"; -import { COLLECTION_LIST_SORT_BY } from "constants/collection"; import { CollectionSummary } from "types/collection"; +import { COLLECTION_LIST_SORT_BY } from "utils/collection"; import AllCollectionContent from "./content"; import AllCollectionsHeader from "./header"; diff --git a/web/apps/photos/src/components/Collections/CollectionInfoWithOptions.tsx b/web/apps/photos/src/components/Collections/CollectionInfoWithOptions.tsx index 925956d607..5f3d00b7dd 100644 --- a/web/apps/photos/src/components/Collections/CollectionInfoWithOptions.tsx +++ b/web/apps/photos/src/components/Collections/CollectionInfoWithOptions.tsx @@ -5,7 +5,7 @@ import LinkIcon from "@mui/icons-material/Link"; import PeopleIcon from "@mui/icons-material/People"; import { SetCollectionNamerAttributes } from "components/Collections/CollectionNamer"; import CollectionOptions from "components/Collections/CollectionOptions"; -import { CollectionSummaryType } from "constants/collection"; +import { CollectionSummaryType } from "utils/collection"; import type { Dispatch, SetStateAction } from "react"; import { Collection, CollectionSummary } from "types/collection"; import { SetFilesDownloadProgressAttributesCreator } from "types/gallery"; diff --git a/web/apps/photos/src/components/Collections/CollectionListBar/CollectionCard.tsx b/web/apps/photos/src/components/Collections/CollectionListBar/CollectionCard.tsx index 9cb8de3124..50b4378929 100644 --- a/web/apps/photos/src/components/Collections/CollectionListBar/CollectionCard.tsx +++ b/web/apps/photos/src/components/Collections/CollectionListBar/CollectionCard.tsx @@ -5,8 +5,8 @@ import PeopleIcon from "@mui/icons-material/People"; import PushPin from "@mui/icons-material/PushPin"; import { Box, Typography, styled } from "@mui/material"; import Tooltip from "@mui/material/Tooltip"; -import { CollectionSummaryType } from "constants/collection"; import { CollectionSummary } from "types/collection"; +import { CollectionSummaryType } from "utils/collection"; import CollectionCard from "../CollectionCard"; import { ActiveIndicator, diff --git a/web/apps/photos/src/components/Collections/CollectionListBar/index.tsx b/web/apps/photos/src/components/Collections/CollectionListBar/index.tsx index 6cab1cfa66..e25cafda7c 100644 --- a/web/apps/photos/src/components/Collections/CollectionListBar/index.tsx +++ b/web/apps/photos/src/components/Collections/CollectionListBar/index.tsx @@ -13,7 +13,6 @@ import { CollectionListBarWrapper, CollectionListWrapper, } from "components/Collections/styledComponents"; -import { ALL_SECTION, COLLECTION_LIST_SORT_BY } from "constants/collection"; import { t } from "i18next"; import memoize from "memoize-one"; import React, { useEffect } from "react"; @@ -24,6 +23,7 @@ import { areEqual, } from "react-window"; import { CollectionSummary } from "types/collection"; +import { ALL_SECTION, COLLECTION_LIST_SORT_BY } from "utils/collection"; import CollectionListSortBy from "../CollectionListSortBy"; import ScrollButton from "./ScrollButton"; diff --git a/web/apps/photos/src/components/Collections/CollectionListSortBy.tsx b/web/apps/photos/src/components/Collections/CollectionListSortBy.tsx index ff3172f52e..86545f9bc5 100644 --- a/web/apps/photos/src/components/Collections/CollectionListSortBy.tsx +++ b/web/apps/photos/src/components/Collections/CollectionListSortBy.tsx @@ -3,8 +3,8 @@ import { OverflowMenuOption } from "@ente/shared/components/OverflowMenu/option" import TickIcon from "@mui/icons-material/Done"; import SortIcon from "@mui/icons-material/Sort"; import SvgIcon from "@mui/material/SvgIcon"; -import { COLLECTION_LIST_SORT_BY } from "constants/collection"; import { t } from "i18next"; +import { COLLECTION_LIST_SORT_BY } from "utils/collection"; interface CollectionSortProps { setSortBy: (sortBy: COLLECTION_LIST_SORT_BY) => void; diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/DownloadQuickOption.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/DownloadQuickOption.tsx index 37dd515293..06b7fcfe0d 100644 --- a/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/DownloadQuickOption.tsx +++ b/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/DownloadQuickOption.tsx @@ -1,7 +1,7 @@ import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined"; import { IconButton, Tooltip } from "@mui/material"; -import { CollectionSummaryType } from "constants/collection"; import { t } from "i18next"; +import { CollectionSummaryType } from "utils/collection"; import { CollectionActions } from ".."; interface Iprops { handleCollectionAction: ( diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/ShareQuickOption.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/ShareQuickOption.tsx index c54dcfd822..9532f94df6 100644 --- a/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/ShareQuickOption.tsx +++ b/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/ShareQuickOption.tsx @@ -1,7 +1,7 @@ import PeopleIcon from "@mui/icons-material/People"; import { IconButton, Tooltip } from "@mui/material"; -import { CollectionSummaryType } from "constants/collection"; import { t } from "i18next"; +import { CollectionSummaryType } from "utils/collection"; import { CollectionActions } from ".."; interface Iprops { diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/index.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/index.tsx index 1d240fc0c5..1087c83ab5 100644 --- a/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/index.tsx +++ b/web/apps/photos/src/components/Collections/CollectionOptions/QuickOptions/index.tsx @@ -1,7 +1,7 @@ import { FlexWrapper } from "@ente/shared/components/Container"; import EnteSpinner from "@ente/shared/components/EnteSpinner"; -import { CollectionSummaryType } from "constants/collection"; import { + CollectionSummaryType, showDownloadQuickOption, showEmptyTrashQuickOption, showShareQuickOption, diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx index a08a7b38cd..65b3a0f3cf 100644 --- a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx +++ b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx @@ -4,11 +4,6 @@ import { HorizontalFlex } from "@ente/shared/components/Container"; import OverflowMenu from "@ente/shared/components/OverflowMenu/menu"; import MoreHoriz from "@mui/icons-material/MoreHoriz"; import { Box } from "@mui/material"; -import { - ALL_SECTION, - CollectionSummaryType, - HIDDEN_ITEMS_SECTION, -} from "constants/collection"; import { t } from "i18next"; import { AppContext } from "pages/_app"; import { GalleryContext } from "pages/gallery"; @@ -20,11 +15,14 @@ import * as TrashService from "services/trashService"; import { Collection } from "types/collection"; import { SetFilesDownloadProgressAttributesCreator } from "types/gallery"; import { + ALL_SECTION, changeCollectionOrder, changeCollectionSortOrder, changeCollectionVisibility, + CollectionSummaryType, downloadCollectionHelper, downloadDefaultHiddenCollectionHelper, + HIDDEN_ITEMS_SECTION, isHiddenCollection, } from "utils/collection"; import { isArchivedCollection, isPinnedCollection } from "utils/magicMetadata"; diff --git a/web/apps/photos/src/components/Collections/CollectionSelector/index.tsx b/web/apps/photos/src/components/Collections/CollectionSelector/index.tsx index ceef31b927..fd9a8525bd 100644 --- a/web/apps/photos/src/components/Collections/CollectionSelector/index.tsx +++ b/web/apps/photos/src/components/Collections/CollectionSelector/index.tsx @@ -2,11 +2,6 @@ import { FlexWrapper } from "@ente/shared/components/Container"; import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton"; import { DialogContent, useMediaQuery } from "@mui/material"; import { AllCollectionDialog } from "components/Collections/AllCollections/dialog"; -import { - COLLECTION_SORT_ORDER, - CollectionSummaryType, - DUMMY_UNCATEGORIZED_COLLECTION, -} from "constants/collection"; import { t } from "i18next"; import { useEffect, useState } from "react"; import { createUnCategorizedCollection } from "services/collectionService"; @@ -17,6 +12,9 @@ import { } from "types/collection"; import { CollectionSelectorIntent } from "types/gallery"; import { + COLLECTION_SORT_ORDER, + CollectionSummaryType, + DUMMY_UNCATEGORIZED_COLLECTION, isAddToAllowedCollection, isMoveToAllowedCollection, } from "utils/collection"; diff --git a/web/apps/photos/src/components/Collections/CollectionShare/index.tsx b/web/apps/photos/src/components/Collections/CollectionShare/index.tsx index e33d60f65d..1cc063b6d0 100644 --- a/web/apps/photos/src/components/Collections/CollectionShare/index.tsx +++ b/web/apps/photos/src/components/Collections/CollectionShare/index.tsx @@ -1,9 +1,9 @@ import { EnteDrawer } from "@/base/components/EnteDrawer"; import { Titlebar } from "@/base/components/Titlebar"; import { DialogProps, Stack } from "@mui/material"; -import { CollectionSummaryType } from "constants/collection"; import { t } from "i18next"; import { Collection, CollectionSummary } from "types/collection"; +import { CollectionSummaryType } from "utils/collection"; import EmailShare from "./emailShare"; import PublicShare from "./publicShare"; import SharingDetails from "./sharingDetails"; diff --git a/web/apps/photos/src/components/Collections/CollectionShare/sharingDetails.tsx b/web/apps/photos/src/components/Collections/CollectionShare/sharingDetails.tsx index ad2abd7f28..889dc4084f 100644 --- a/web/apps/photos/src/components/Collections/CollectionShare/sharingDetails.tsx +++ b/web/apps/photos/src/components/Collections/CollectionShare/sharingDetails.tsx @@ -9,11 +9,11 @@ import ModeEditIcon from "@mui/icons-material/ModeEdit"; import Photo from "@mui/icons-material/Photo"; import { Stack } from "@mui/material"; import Avatar from "components/pages/gallery/Avatar"; -import { CollectionSummaryType } from "constants/collection"; import { t } from "i18next"; import { GalleryContext } from "pages/gallery"; import { useContext } from "react"; import { COLLECTION_ROLE } from "types/collection"; +import { CollectionSummaryType } from "utils/collection"; export default function SharingDetails({ collection, type }) { const galleryContext = useContext(GalleryContext); diff --git a/web/apps/photos/src/components/Collections/index.tsx b/web/apps/photos/src/components/Collections/index.tsx index c16d56ee52..91c1a51082 100644 --- a/web/apps/photos/src/components/Collections/index.tsx +++ b/web/apps/photos/src/components/Collections/index.tsx @@ -6,12 +6,13 @@ import CollectionListBar from "components/Collections/CollectionListBar"; import { SetCollectionNamerAttributes } from "components/Collections/CollectionNamer"; import CollectionShare from "components/Collections/CollectionShare"; import { ITEM_TYPE, TimeStampListItem } from "components/PhotoList"; -import { ALL_SECTION, COLLECTION_LIST_SORT_BY } from "constants/collection"; import { useCallback, useEffect, useMemo, useState } from "react"; import { sortCollectionSummaries } from "services/collectionService"; import { Collection, CollectionSummaries } from "types/collection"; import { SetFilesDownloadProgressAttributesCreator } from "types/gallery"; import { + ALL_SECTION, + COLLECTION_LIST_SORT_BY, hasNonSystemCollections, isSystemCollection, shouldBeShownOnCollectionBar, diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsx index c88d9dde1b..69a0710b5a 100644 --- a/web/apps/photos/src/components/PhotoFrame.tsx +++ b/web/apps/photos/src/components/PhotoFrame.tsx @@ -8,7 +8,7 @@ import { CustomError } from "@ente/shared/error"; import useMemoSingleThreaded from "@ente/shared/hooks/useMemoSingleThreaded"; import { styled } from "@mui/material"; import PhotoViewer from "components/PhotoViewer"; -import { TRASH_SECTION } from "constants/collection"; +import { TRASH_SECTION } from "utils/collection"; import { useRouter } from "next/router"; import { GalleryContext } from "pages/gallery"; import PhotoSwipe from "photoswipe"; diff --git a/web/apps/photos/src/components/Sidebar/index.tsx b/web/apps/photos/src/components/Sidebar/index.tsx index 478acba9bb..88bfdbf75b 100644 --- a/web/apps/photos/src/components/Sidebar/index.tsx +++ b/web/apps/photos/src/components/Sidebar/index.tsx @@ -40,11 +40,6 @@ import DeleteAccountModal from "components/DeleteAccountModal"; import TwoFactorModal from "components/TwoFactor/Modal"; import { WatchFolder } from "components/WatchFolder"; import LinkButton from "components/pages/gallery/LinkButton"; -import { - ARCHIVE_SECTION, - DUMMY_UNCATEGORIZED_COLLECTION, - TRASH_SECTION, -} from "constants/collection"; import { t } from "i18next"; import isElectron from "is-electron"; import { useRouter } from "next/router"; @@ -74,6 +69,11 @@ import { isSubscriptionCancelled, isSubscriptionPastDue, } from "utils/billing"; +import { + ARCHIVE_SECTION, + DUMMY_UNCATEGORIZED_COLLECTION, + TRASH_SECTION, +} from "utils/collection"; import { getDownloadAppMessage } from "utils/ui"; import { isFamilyAdmin, isPartOfFamily } from "utils/user/family"; import { testUpload } from "../../../tests/upload.test"; diff --git a/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx b/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx index 81c567e2eb..3951b82be8 100644 --- a/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx +++ b/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx @@ -12,12 +12,12 @@ import { LoadingThumbnail, StaticThumbnail, } from "components/PlaceholderThumbnails"; -import { TRASH_SECTION } from "constants/collection"; import { GAP_BTW_TILES, IMAGE_CONTAINER_MAX_WIDTH } from "constants/gallery"; import i18n from "i18next"; import { DeduplicateContext } from "pages/deduplicate"; import { GalleryContext } from "pages/gallery"; import React, { useContext, useEffect, useRef, useState } from "react"; +import { TRASH_SECTION } from "utils/collection"; import { shouldShowAvatar } from "utils/file"; import Avatar from "./Avatar"; diff --git a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx index d860c1839e..01182abfa9 100644 --- a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx +++ b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx @@ -13,11 +13,6 @@ import UnArchiveIcon from "@mui/icons-material/Unarchive"; import VisibilityOffOutlined from "@mui/icons-material/VisibilityOffOutlined"; import VisibilityOutlined from "@mui/icons-material/VisibilityOutlined"; import { Box, IconButton, Stack, Tooltip } from "@mui/material"; -import { - ALL_SECTION, - ARCHIVE_SECTION, - TRASH_SECTION, -} from "constants/collection"; import { t } from "i18next"; import { AppContext } from "pages/_app"; import { useContext } from "react"; @@ -26,7 +21,12 @@ import { CollectionSelectorIntent, SetCollectionSelectorAttributes, } from "types/gallery"; -import { COLLECTION_OPS_TYPE } from "utils/collection"; +import { + ALL_SECTION, + ARCHIVE_SECTION, + COLLECTION_OPS_TYPE, + TRASH_SECTION, +} from "utils/collection"; import { FILE_OPS_TYPE } from "utils/file"; import { formatNumber } from "utils/number/format"; import { getTrashFilesMessage } from "utils/ui"; diff --git a/web/apps/photos/src/constants/collection.ts b/web/apps/photos/src/constants/collection.ts index c8c9d7b08b..e69de29bb2 100644 --- a/web/apps/photos/src/constants/collection.ts +++ b/web/apps/photos/src/constants/collection.ts @@ -1,54 +0,0 @@ -export const ARCHIVE_SECTION = -1; -export const TRASH_SECTION = -2; -export const DUMMY_UNCATEGORIZED_COLLECTION = -3; -export const HIDDEN_ITEMS_SECTION = -4; -export const ALL_SECTION = 0; - -export enum CollectionType { - folder = "folder", - favorites = "favorites", - album = "album", - uncategorized = "uncategorized", -} - -export enum CollectionSummaryType { - folder = "folder", - favorites = "favorites", - album = "album", - archive = "archive", - trash = "trash", - uncategorized = "uncategorized", - all = "all", - outgoingShare = "outgoingShare", - incomingShareViewer = "incomingShareViewer", - incomingShareCollaborator = "incomingShareCollaborator", - sharedOnlyViaLink = "sharedOnlyViaLink", - archived = "archived", - defaultHidden = "defaultHidden", - hiddenItems = "hiddenItems", - pinned = "pinned", -} -export enum COLLECTION_LIST_SORT_BY { - NAME, - CREATION_TIME_ASCENDING, - UPDATION_TIME_DESCENDING, -} - -export const COLLECTION_SORT_ORDER = new Map([ - [CollectionSummaryType.all, 0], - [CollectionSummaryType.hiddenItems, 0], - [CollectionSummaryType.uncategorized, 1], - [CollectionSummaryType.favorites, 2], - [CollectionSummaryType.pinned, 3], - [CollectionSummaryType.album, 4], - [CollectionSummaryType.folder, 4], - [CollectionSummaryType.incomingShareViewer, 4], - [CollectionSummaryType.incomingShareCollaborator, 4], - [CollectionSummaryType.outgoingShare, 4], - [CollectionSummaryType.sharedOnlyViaLink, 4], - [CollectionSummaryType.archived, 4], - [CollectionSummaryType.archive, 5], - [CollectionSummaryType.trash, 6], - [CollectionSummaryType.defaultHidden, 7], -]); - diff --git a/web/apps/photos/src/pages/deduplicate.tsx b/web/apps/photos/src/pages/deduplicate.tsx index d429e0da67..df8e610ca4 100644 --- a/web/apps/photos/src/pages/deduplicate.tsx +++ b/web/apps/photos/src/pages/deduplicate.tsx @@ -11,7 +11,6 @@ import Typography from "@mui/material/Typography"; import { HttpStatusCode } from "axios"; import DeduplicateOptions from "components/pages/dedupe/SelectedFileOptions"; import PhotoFrame from "components/PhotoFrame"; -import { ALL_SECTION } from "constants/collection"; import { t } from "i18next"; import { default as Router, default as router } from "next/router"; import { AppContext } from "pages/_app"; @@ -28,6 +27,7 @@ import { DefaultDeduplicateContext, } from "types/deduplicate"; import { SelectedState } from "types/gallery"; +import { ALL_SECTION } from "utils/collection"; import { constructFileToCollectionMap, getSelectedFiles } from "utils/file"; export const DeduplicateContext = createContext( diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx index 2950e7c30f..10306185f7 100644 --- a/web/apps/photos/src/pages/gallery.tsx +++ b/web/apps/photos/src/pages/gallery.tsx @@ -75,13 +75,6 @@ import Uploader from "components/Upload/Uploader"; import { UploadSelectorInputs } from "components/UploadSelectorInputs"; import PlanSelector from "components/pages/gallery/PlanSelector"; import SelectedFileOptions from "components/pages/gallery/SelectedFileOptions"; -import { - ALL_SECTION, - ARCHIVE_SECTION, - CollectionSummaryType, - HIDDEN_ITEMS_SECTION, - TRASH_SECTION, -} from "constants/collection"; import { SYNC_INTERVAL_IN_MICROSECONDS } from "constants/gallery"; import { t } from "i18next"; import { useRouter } from "next/router"; @@ -121,7 +114,12 @@ import { import { FamilyData } from "types/user"; import { checkSubscriptionPurchase } from "utils/billing"; import { + ALL_SECTION, + ARCHIVE_SECTION, COLLECTION_OPS_TYPE, + CollectionSummaryType, + HIDDEN_ITEMS_SECTION, + TRASH_SECTION, constructCollectionNameMap, getArchivedCollections, getDefaultHiddenCollectionIDs, diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx index bd87a4922a..c65bba6fe3 100644 --- a/web/apps/photos/src/pages/shared-albums.tsx +++ b/web/apps/photos/src/pages/shared-albums.tsx @@ -39,7 +39,6 @@ import Uploader from "components/Upload/Uploader"; import { UploadSelectorInputs } from "components/UploadSelectorInputs"; import SharedAlbumNavbar from "components/pages/sharedAlbum/Navbar"; import SelectedFileOptions from "components/pages/sharedAlbum/SelectedFileOptions"; -import { ALL_SECTION } from "constants/collection"; import { t } from "i18next"; import { useRouter } from "next/router"; import { AppContext } from "pages/_app"; @@ -64,7 +63,11 @@ import { SetFilesDownloadProgressAttributes, SetFilesDownloadProgressAttributesCreator, } from "types/gallery"; -import { downloadCollectionFiles, isHiddenCollection } from "utils/collection"; +import { + ALL_SECTION, + downloadCollectionFiles, + isHiddenCollection, +} from "utils/collection"; import { downloadSelectedFiles, getSelectedFiles, sortFiles } from "utils/file"; import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery"; diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts index 7fef72c532..669d6cea15 100644 --- a/web/apps/photos/src/services/collectionService.ts +++ b/web/apps/photos/src/services/collectionService.ts @@ -17,17 +17,6 @@ import { LS_KEYS, getData } from "@ente/shared/storage/localStorage"; import { getToken } from "@ente/shared/storage/localStorage/helpers"; import { getActualKey } from "@ente/shared/user"; import type { User } from "@ente/shared/user/types"; -import { - ALL_SECTION, - ARCHIVE_SECTION, - COLLECTION_LIST_SORT_BY, - COLLECTION_SORT_ORDER, - CollectionSummaryType, - CollectionType, - DUMMY_UNCATEGORIZED_COLLECTION, - HIDDEN_ITEMS_SECTION, - TRASH_SECTION, -} from "constants/collection"; import { t } from "i18next"; import { AddToCollectionRequest, @@ -50,6 +39,15 @@ import { } from "types/collection"; import { FamilyData } from "types/user"; import { + ALL_SECTION, + ARCHIVE_SECTION, + COLLECTION_LIST_SORT_BY, + COLLECTION_SORT_ORDER, + CollectionSummaryType, + CollectionType, + DUMMY_UNCATEGORIZED_COLLECTION, + HIDDEN_ITEMS_SECTION, + TRASH_SECTION, changeCollectionSubType, getHiddenCollections, getNonHiddenCollections, diff --git a/web/apps/photos/src/types/collection/index.ts b/web/apps/photos/src/types/collection/index.ts index 4997cd73de..5a2fcef3cc 100644 --- a/web/apps/photos/src/types/collection/index.ts +++ b/web/apps/photos/src/types/collection/index.ts @@ -5,7 +5,7 @@ import { MagicMetadataCore, SUB_TYPE, } from "@/new/photos/types/magicMetadata"; -import { CollectionSummaryType, CollectionType } from "constants/collection"; +import { CollectionSummaryType, CollectionType } from "utils/collection"; export enum COLLECTION_ROLE { VIEWER = "VIEWER", diff --git a/web/apps/photos/src/utils/collection/index.ts b/web/apps/photos/src/utils/collection/index.ts index 6e9b1b0f4b..32f2ff424e 100644 --- a/web/apps/photos/src/utils/collection/index.ts +++ b/web/apps/photos/src/utils/collection/index.ts @@ -10,11 +10,6 @@ import { LS_KEYS, getData } from "@ente/shared/storage/localStorage"; import { getUnixTimeInMicroSecondsWithDelta } from "@ente/shared/time"; import type { User } from "@ente/shared/user/types"; import bs58 from "bs58"; -import { - CollectionSummaryType, - CollectionType, - DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME, -} from "constants/collection"; import { t } from "i18next"; import { addToCollection, @@ -41,6 +36,60 @@ import { SetFilesDownloadProgressAttributes } from "types/gallery"; import { downloadFilesWithProgress } from "utils/file"; import { isArchivedCollection, updateMagicMetadata } from "utils/magicMetadata"; +export const ARCHIVE_SECTION = -1; +export const TRASH_SECTION = -2; +export const DUMMY_UNCATEGORIZED_COLLECTION = -3; +export const HIDDEN_ITEMS_SECTION = -4; +export const ALL_SECTION = 0; + +export enum CollectionType { + folder = "folder", + favorites = "favorites", + album = "album", + uncategorized = "uncategorized", +} + +export enum CollectionSummaryType { + folder = "folder", + favorites = "favorites", + album = "album", + archive = "archive", + trash = "trash", + uncategorized = "uncategorized", + all = "all", + outgoingShare = "outgoingShare", + incomingShareViewer = "incomingShareViewer", + incomingShareCollaborator = "incomingShareCollaborator", + sharedOnlyViaLink = "sharedOnlyViaLink", + archived = "archived", + defaultHidden = "defaultHidden", + hiddenItems = "hiddenItems", + pinned = "pinned", +} +export enum COLLECTION_LIST_SORT_BY { + NAME, + CREATION_TIME_ASCENDING, + UPDATION_TIME_DESCENDING, +} + +export const COLLECTION_SORT_ORDER = new Map([ + [CollectionSummaryType.all, 0], + [CollectionSummaryType.hiddenItems, 0], + [CollectionSummaryType.uncategorized, 1], + [CollectionSummaryType.favorites, 2], + [CollectionSummaryType.pinned, 3], + [CollectionSummaryType.album, 4], + [CollectionSummaryType.folder, 4], + [CollectionSummaryType.incomingShareViewer, 4], + [CollectionSummaryType.incomingShareCollaborator, 4], + [CollectionSummaryType.outgoingShare, 4], + [CollectionSummaryType.sharedOnlyViaLink, 4], + [CollectionSummaryType.archived, 4], + [CollectionSummaryType.archive, 5], + [CollectionSummaryType.trash, 6], + [CollectionSummaryType.defaultHidden, 7], +]); + const SYSTEM_COLLECTION_TYPES = new Set([ CollectionSummaryType.all, CollectionSummaryType.archive,