Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Rename

Manav Rathi2660cee26343
diff --git a/web/apps/photos/src/components/Collections/AllCollections/index.tsx b/web/apps/photos/src/components/Collections/AllCollections/index.tsx
index 362d65c138..5913896c10 100644
--- a/web/apps/photos/src/components/Collections/AllCollections/index.tsx
+++ b/web/apps/photos/src/components/Collections/AllCollections/index.tsx
@@ -4,7 +4,7 @@ import {
AllCollectionDialog,
Transition,
} from "components/Collections/AllCollections/dialog";
-import { COLLECTION_LIST_SORT_BY } from "utils/collection";
+import { CollectionListSortBy } from "utils/collection";
import AllCollectionContent from "./content";
import AllCollectionsHeader from "./header";
@@ -13,8 +13,8 @@ interface Iprops {
onClose: () => void;
collectionSummaries: CollectionSummary[];
setActiveCollectionID: (id?: number) => void;
- collectionListSortBy: COLLECTION_LIST_SORT_BY;
- setCollectionListSortBy: (v: COLLECTION_LIST_SORT_BY) => void;
+ collectionListSortBy: CollectionListSortBy;
+ setCollectionListSortBy: (v: CollectionListSortBy) => void;
isInHiddenSection: boolean;
}
diff --git a/web/apps/photos/src/components/Collections/CollectionListBar.tsx b/web/apps/photos/src/components/Collections/CollectionListBar.tsx
index 46d616bcba..339532ffd4 100644
--- a/web/apps/photos/src/components/Collections/CollectionListBar.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionListBar.tsx
@@ -31,7 +31,7 @@ import React, {
} from "react";
import AutoSizer from "react-virtualized-auto-sizer";
import { FixedSizeList, ListChildComponentProps, areEqual } from "react-window";
-import { COLLECTION_LIST_SORT_BY } from "utils/collection";
+import { CollectionListSortBy } from "utils/collection";
import type { GalleryBarMode } from ".";
import { CollectionListSortOptions } from "./CollectionListSortOptions";
@@ -65,11 +65,11 @@ export interface CollectionListBarProps {
* The sort order that should be used for showing the collections in the
* bar.
*/
- collectionListSortBy: COLLECTION_LIST_SORT_BY;
+ collectionListSortBy: CollectionListSortBy;
/**
* Called when the user changes the sort order.
*/
- setCollectionListSortBy: (v: COLLECTION_LIST_SORT_BY) => void;
+ setCollectionListSortBy: (v: CollectionListSortBy) => 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.tsx
index 152d8cf561..95a22f98bf 100644
--- a/web/apps/photos/src/components/Collections/CollectionListSortOptions.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionListSortOptions.tsx
@@ -4,18 +4,18 @@ 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 { COLLECTION_LIST_SORT_BY } from "utils/collection";
+import { CollectionListSortBy } from "utils/collection";
interface CollectionListSortOptionsProps {
- setSortBy: (sortBy: COLLECTION_LIST_SORT_BY) => void;
- activeSortBy: COLLECTION_LIST_SORT_BY;
+ setSortBy: (sortBy: CollectionListSortBy) => void;
+ activeSortBy: CollectionListSortBy;
nestedInDialog?: boolean;
disableBG?: boolean;
}
const SortByOptionCreator =
({ setSortBy, activeSortBy }: CollectionListSortOptionsProps) =>
- (props: { sortBy: COLLECTION_LIST_SORT_BY; children: any }) => {
+ (props: { sortBy: CollectionListSortBy; children: any }) => {
const handleClick = () => {
setSortBy(props.sortBy);
};
@@ -55,17 +55,13 @@ export const CollectionListSortOptions: React.FC<
},
}}
>
- <SortByOption sortBy={COLLECTION_LIST_SORT_BY.NAME}>
+ <SortByOption sortBy={CollectionListSortBy.Name}>
{t("sort_by_name")}
</SortByOption>
- <SortByOption
- sortBy={COLLECTION_LIST_SORT_BY.CREATION_TIME_ASCENDING}
- >
+ <SortByOption sortBy={CollectionListSortBy.CreationTimeAscending}>
{t("sort_by_creation_time_ascending")}
</SortByOption>
- <SortByOption
- sortBy={COLLECTION_LIST_SORT_BY.UPDATION_TIME_DESCENDING}
- >
+ <SortByOption sortBy={CollectionListSortBy.UpdationTimeDescending}>
{t("sort_by_updation_time_descending")}
</SortByOption>
</OverflowMenu>
diff --git a/web/apps/photos/src/components/Collections/index.tsx b/web/apps/photos/src/components/Collections/index.tsx
index c838c7373e..a27a9ef846 100644
--- a/web/apps/photos/src/components/Collections/index.tsx
+++ b/web/apps/photos/src/components/Collections/index.tsx
@@ -14,7 +14,7 @@ import { sortCollectionSummaries } from "services/collectionService";
import { SetFilesDownloadProgressAttributesCreator } from "types/gallery";
import {
ALL_SECTION,
- COLLECTION_LIST_SORT_BY,
+ CollectionListSortBy,
hasNonSystemCollections,
isSystemCollection,
shouldBeShownOnCollectionBar,
@@ -75,9 +75,9 @@ export const Collections: React.FC<CollectionsProps> = ({
const [openAlbumCastDialog, setOpenAlbumCastDialog] = useState(false);
const [collectionListSortBy, setCollectionListSortBy] =
- useLocalState<COLLECTION_LIST_SORT_BY>(
+ useLocalState<CollectionListSortBy>(
LS_KEYS.COLLECTION_SORT_BY,
- COLLECTION_LIST_SORT_BY.UPDATION_TIME_DESCENDING,
+ CollectionListSortBy.UpdationTimeDescending,
);
const toShowCollectionSummaries = useMemo(
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts
index 7c7c148e3e..c99184d7de 100644
--- a/web/apps/photos/src/services/collectionService.ts
+++ b/web/apps/photos/src/services/collectionService.ts
@@ -44,8 +44,8 @@ import { FamilyData } from "types/user";
import {
ALL_SECTION,
ARCHIVE_SECTION,
- COLLECTION_LIST_SORT_BY,
COLLECTION_SORT_ORDER,
+ CollectionListSortBy,
DUMMY_UNCATEGORIZED_COLLECTION,
HIDDEN_ITEMS_SECTION,
TRASH_SECTION,
@@ -1070,19 +1070,19 @@ export const getFavCollection = async () => {
export function sortCollectionSummaries(
collectionSummaries: CollectionSummary[],
- sortBy: COLLECTION_LIST_SORT_BY,
+ sortBy: CollectionListSortBy,
) {
return collectionSummaries
.sort((a, b) => {
switch (sortBy) {
- case COLLECTION_LIST_SORT_BY.CREATION_TIME_ASCENDING:
+ case CollectionListSortBy.CreationTimeAscending:
return (
-1 *
compareCollectionsLatestFile(b.latestFile, a.latestFile)
);
- case COLLECTION_LIST_SORT_BY.UPDATION_TIME_DESCENDING:
+ case CollectionListSortBy.UpdationTimeDescending:
return b.updationTime - a.updationTime;
- case COLLECTION_LIST_SORT_BY.NAME:
+ case CollectionListSortBy.Name:
return a.name.localeCompare(b.name);
}
})
diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.ts
index 9f18df53f8..32940c6612 100644
--- a/web/apps/photos/src/utils/collection.ts
+++ b/web/apps/photos/src/utils/collection.ts
@@ -45,10 +45,14 @@ export const DUMMY_UNCATEGORIZED_COLLECTION = -3;
export const HIDDEN_ITEMS_SECTION = -4;
export const ALL_SECTION = 0;
-export enum COLLECTION_LIST_SORT_BY {
- NAME,
- CREATION_TIME_ASCENDING,
- UPDATION_TIME_DESCENDING,
+/**
+ * Sort orders for use when we're showing lists of collections (e.g. in the
+ * collection bar).
+ */
+export enum CollectionListSortBy {
+ Name,
+ CreationTimeAscending,
+ UpdationTimeDescending,
}
export const COLLECTION_SORT_ORDER = new Map<CollectionSummaryType, number>([