π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Unenum
Manav Rathie62dfe0a0741
diff --git a/web/apps/photos/src/components/Collections/AllCollections/index.tsx b/web/apps/photos/src/components/Collections/AllCollections/index.tsxindex 76ea032f45..89aeb46568 100644--- a/web/apps/photos/src/components/Collections/AllCollections/index.tsx+++ b/web/apps/photos/src/components/Collections/AllCollections/index.tsx@@ -1,5 +1,5 @@import type { CollectionSummary } from "@/new/photos/types/collection";-import { CollectionListSortBy } from "@/new/photos/types/collection";+import { CollectionListSortOrder } from "@/new/photos/types/collection";import { Divider, useMediaQuery } from "@mui/material";import {AllCollectionDialog,@@ -13,8 +13,8 @@ interface Iprops {onClose: () => void;collectionSummaries: CollectionSummary[];setActiveCollectionID: (id?: number) => void;- collectionListSortBy: CollectionListSortBy;- setCollectionListSortBy: (v: CollectionListSortBy) => void;+ collectionListSortBy: CollectionListSortOrder;+ setCollectionListSortBy: (v: CollectionListSortOrder) => void;isInHiddenSection: boolean;}diff --git a/web/apps/photos/src/components/Collections/CollectionListBar.tsx b/web/apps/photos/src/components/Collections/CollectionListBar.tsxindex 866b58e2ae..6ae04206d3 100644--- a/web/apps/photos/src/components/Collections/CollectionListBar.tsx+++ b/web/apps/photos/src/components/Collections/CollectionListBar.tsx@@ -2,10 +2,10 @@ import { useIsMobileWidth } from "@/base/hooks";import { BarItemTile, ItemCard } from "@/new/photos/components/ItemCards";import type { Person } from "@/new/photos/services/ml/cgroups";import type {+ CollectionListSortOrder,CollectionSummary,CollectionSummaryType,} from "@/new/photos/types/collection";-import { CollectionListSortBy } from "@/new/photos/types/collection";import { ensure } from "@/utils/ensure";import { IconButtonWithBG, Overlay } from "@ente/shared/components/Container";import ArchiveIcon from "@mui/icons-material/Archive";@@ -65,11 +65,11 @@ export interface CollectionListBarProps {* The sort order that should be used for showing the collections in the* bar.*/- collectionListSortBy: CollectionListSortBy;+ collectionListSortBy: CollectionListSortOrder;/*** Called when the user changes the sort order.*/- setCollectionListSortBy: (v: CollectionListSortBy) => void;+ setCollectionListSortBy: (order: CollectionListSortOrder) => void;/*** The list of people that should be shown in the bar.*/diff --git a/web/apps/photos/src/components/Collections/CollectionListSortOptions.tsx b/web/apps/photos/src/components/Collections/CollectionListSortOptions.tsxindex 46b0644e13..87062d4e1f 100644--- a/web/apps/photos/src/components/Collections/CollectionListSortOptions.tsx+++ b/web/apps/photos/src/components/Collections/CollectionListSortOptions.tsx@@ -1,37 +1,18 @@+import type { CollectionListSortOrder } from "@/new/photos/types/collection";import OverflowMenu from "@ente/shared/components/OverflowMenu/menu";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 { t } from "i18next";-import { CollectionListSortBy } from "@/new/photos/types/collection";interface CollectionListSortOptionsProps {- setSortBy: (sortBy: CollectionListSortBy) => void;- activeSortBy: CollectionListSortBy;+ setSortBy: (order: CollectionListSortOrder) => void;+ activeSortBy: CollectionListSortOrder;nestedInDialog?: boolean;disableBG?: boolean;}-const SortByOptionCreator =- ({ setSortBy, activeSortBy }: CollectionListSortOptionsProps) =>- (props: { sortBy: CollectionListSortBy; children: any }) => {- const handleClick = () => {- setSortBy(props.sortBy);- };-- return (- <OverflowMenuOption- onClick={handleClick}- endIcon={- activeSortBy === props.sortBy ? <TickIcon /> : <SvgIcon />- }- >- {props.children}- </OverflowMenuOption>- );- };-export const CollectionListSortOptions: React.FC<CollectionListSortOptionsProps> = (props) => {@@ -55,15 +36,32 @@ export const CollectionListSortOptions: React.FC<},}}>- <SortByOption sortBy={CollectionListSortBy.Name}>- {t("sort_by_name")}- </SortByOption>- <SortByOption sortBy={CollectionListSortBy.CreationTimeAscending}>+ <SortByOption sortBy="name">{t("sort_by_name")}</SortByOption>+ <SortByOption sortBy="creation-time-asc">{t("sort_by_creation_time_ascending")}</SortByOption>- <SortByOption sortBy={CollectionListSortBy.UpdationTimeDescending}>+ <SortByOption sortBy="updation-time-desc">{t("sort_by_updation_time_descending")}</SortByOption></OverflowMenu>);};++const SortByOptionCreator =+ ({ setSortBy, activeSortBy }: CollectionListSortOptionsProps) =>+ (props: { sortBy: CollectionListSortOrder; children: any }) => {+ const handleClick = () => {+ setSortBy(props.sortBy);+ };++ return (+ <OverflowMenuOption+ onClick={handleClick}+ endIcon={+ activeSortBy === props.sortBy ? <TickIcon /> : <SvgIcon />+ }+ >+ {props.children}+ </OverflowMenuOption>+ );+ };diff --git a/web/apps/photos/src/components/Collections/index.tsx b/web/apps/photos/src/components/Collections/index.tsxindex a5d7fde425..8f39d9a516 100644--- a/web/apps/photos/src/components/Collections/index.tsx+++ b/web/apps/photos/src/components/Collections/index.tsx@@ -1,7 +1,9 @@import type { Collection } from "@/media/collection";import type { Person } from "@/new/photos/services/ml/cgroups";-import type { CollectionSummaries } from "@/new/photos/types/collection";-import { CollectionListSortBy } from "@/new/photos/types/collection";+import type {+ CollectionListSortOrder,+ CollectionSummaries,+} from "@/new/photos/types/collection";import { useLocalState } from "@ente/shared/hooks/useLocalState";import { LS_KEYS } from "@ente/shared/storage/localStorage";import AllCollections from "components/Collections/AllCollections";@@ -75,9 +77,9 @@ export const Collections: React.FC<CollectionsProps> = ({const [openAlbumCastDialog, setOpenAlbumCastDialog] = useState(false);const [collectionListSortBy, setCollectionListSortBy] =- useLocalState<CollectionListSortBy>(+ useLocalState<CollectionListSortOrder>(LS_KEYS.COLLECTION_SORT_BY,- CollectionListSortBy.UpdationTimeDescending,+ "updation-time-desc",);const toShowCollectionSummaries = useMemo(diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.tsindex 722ab9ac16..7fd48e48d9 100644--- a/web/apps/photos/src/services/collectionService.ts+++ b/web/apps/photos/src/services/collectionService.ts@@ -25,6 +25,7 @@ import type {CollectionSummary,CollectionSummaryType,} from "@/new/photos/types/collection";+import { CollectionListSortOrder } from "@/new/photos/types/collection";import { EnteFile } from "@/new/photos/types/file";import {EncryptedMagicMetadata,@@ -60,7 +61,6 @@ import {isSharedOnlyViaLink,isValidMoveTarget,} from "utils/collection";-import { CollectionListSortBy } from "@/new/photos/types/collection";import {getUniqueFiles,groupFilesBasedOnCollectionID,@@ -1070,20 +1070,20 @@ export const getFavCollection = async () => {export function sortCollectionSummaries(collectionSummaries: CollectionSummary[],- sortBy: CollectionListSortBy,+ sortBy: CollectionListSortOrder,) {return collectionSummaries.sort((a, b) => {switch (sortBy) {- case CollectionListSortBy.CreationTimeAscending:+ case "name":+ return a.name.localeCompare(b.name);+ case "creation-time-asc":return (-1 *compareCollectionsLatestFile(b.latestFile, a.latestFile));- case CollectionListSortBy.UpdationTimeDescending:+ case "updation-time-desc":return b.updationTime - a.updationTime;- case CollectionListSortBy.Name:- return a.name.localeCompare(b.name);}}).sort((a, b) => b.order ?? 0 - a.order ?? 0)diff --git a/web/packages/new/photos/types/collection.ts b/web/packages/new/photos/types/collection.tsindex 99622fc9b8..993c6992ca 100644--- a/web/packages/new/photos/types/collection.ts+++ b/web/packages/new/photos/types/collection.ts@@ -36,11 +36,10 @@ export interface CollectionSummary {export type CollectionSummaries = Map<number, CollectionSummary>;/**- * Sort orders for use when we're showing lists of collections (e.g. in the+ * Sort order for use when we're showing lists of collections (e.g. in the* collection bar).*/-export enum CollectionListSortBy {- Name,- CreationTimeAscending,- UpdationTimeDescending,-}+export type CollectionListSortOrder =+ | "name"+ | "creation-time-asc"+ | "updation-time-desc";