Skip to content

armgit / ente

Public Imported from GitHub
0

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

Conv

Manav Rathi21d3f42e2a74
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsx
index 54daf7a82d..33ea623977 100644
--- a/web/apps/photos/src/components/FileList.tsx
+++ b/web/apps/photos/src/components/FileList.tsx
@@ -25,7 +25,7 @@ import {
StaticThumbnail,
} from "ente-new/photos/components/PlaceholderThumbnails";
import { TileBottomTextOverlay } from "ente-new/photos/components/Tiles";
-import { TRASH_SECTION } from "ente-new/photos/services/collection";
+import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";
import { t } from "i18next";
import memoize from "memoize-one";
import { GalleryContext } from "pages/gallery";
@@ -1282,13 +1282,14 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({
<InSelectRangeOverlay />
)}
- {activeCollectionID === TRASH_SECTION && file.isTrashed && (
- <TileBottomTextOverlay>
- <Typography variant="small">
- {formattedDateRelative(enteFileDeletionDate(file))}
- </Typography>
- </TileBottomTextOverlay>
- )}
+ {activeCollectionID == PseudoCollectionID.trash &&
+ file.isTrashed && (
+ <TileBottomTextOverlay>
+ <Typography variant="small">
+ {formattedDateRelative(enteFileDeletionDate(file))}
+ </Typography>
+ </TileBottomTextOverlay>
+ )}
</FileThumbnail_>
);
};
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index e071c99c52..5e7680e3e6 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -7,10 +7,8 @@ import {
} from "ente-gallery/components/viewer/FileViewer";
import type { Collection } from "ente-media/collection";
import { EnteFile } from "ente-media/file";
-import {
- moveToTrash,
- TRASH_SECTION,
-} from "ente-new/photos/services/collection";
+import { moveToTrash } from "ente-new/photos/services/collection";
+import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";
import { t } from "i18next";
import { useCallback, useMemo, useState } from "react";
import AutoSizer from "react-virtualized-auto-sizer";
@@ -189,7 +187,9 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
onClose={handleCloseFileViewer}
initialIndex={currentIndex}
disableDownload={!enableDownload}
- isInTrashSection={activeCollectionID === TRASH_SECTION}
+ isInTrashSection={
+ activeCollectionID == PseudoCollectionID.trash
+ }
{...{
user,
files,
diff --git a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx
index af79920ec6..d5a0f94151 100644
--- a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx
+++ b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx
@@ -17,11 +17,8 @@ import { useBaseContext } from "ente-base/context";
import type { Collection } from "ente-media/collection";
import type { CollectionSelectorAttributes } from "ente-new/photos/components/CollectionSelector";
import type { GalleryBarMode } from "ente-new/photos/components/gallery/reducer";
-import {
- ALL_SECTION,
- ARCHIVE_SECTION,
- TRASH_SECTION,
-} from "ente-new/photos/services/collection";
+import { ALL_SECTION } from "ente-new/photos/services/collection";
+import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";
import { t } from "i18next";
import { type CollectionOp } from "utils/collection";
import { type FileOp } from "utils/file";
@@ -252,7 +249,7 @@ const SelectedFileOptions = ({
</IconButton>
</Tooltip>
</>
- ) : activeCollectionID === TRASH_SECTION ? (
+ ) : activeCollectionID == PseudoCollectionID.trash ? (
<>
<Tooltip title={t("restore")}>
<IconButton onClick={restoreHandler}>
@@ -316,7 +313,8 @@ const SelectedFileOptions = ({
</IconButton>
</Tooltip>
{!isFavoriteCollection &&
- activeCollectionID != ARCHIVE_SECTION && (
+ activeCollectionID !=
+ PseudoCollectionID.archiveItems && (
<Tooltip title={t("favorite")}>
<IconButton onClick={handleFileOp("favorite")}>
<FavoriteBorderIcon />
@@ -333,7 +331,7 @@ const SelectedFileOptions = ({
<AddIcon />
</IconButton>
</Tooltip>
- {activeCollectionID === ARCHIVE_SECTION && (
+ {activeCollectionID == PseudoCollectionID.archiveItems && (
<Tooltip title={t("unarchive")}>
<IconButton onClick={handleFileOp("unarchive")}>
<UnArchiveIcon />
@@ -348,7 +346,7 @@ const SelectedFileOptions = ({
</Tooltip>
)}
{activeCollectionID !== ALL_SECTION &&
- activeCollectionID !== ARCHIVE_SECTION &&
+ activeCollectionID != PseudoCollectionID.archiveItems &&
!isFavoriteCollection && (
<>
<Tooltip title={t("move")}>
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index b7066b5347..8e6c2b48b0 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -17,12 +17,10 @@ import { t } from "i18next";
import React, { useReducer } from "react";
import {
ALL_SECTION,
- ARCHIVE_SECTION,
findDefaultHiddenCollectionIDs,
HIDDEN_ITEMS_SECTION,
isDefaultHiddenCollection,
isIncomingShare,
- TRASH_SECTION,
} from "../../services/collection";
import {
PseudoCollectionID,
@@ -1301,9 +1299,9 @@ const deriveNormalCollectionSummaries = (
attributes: ["all"],
name: t("section_all"),
});
- normalCollectionSummaries.set(TRASH_SECTION, {
+ normalCollectionSummaries.set(PseudoCollectionID.trash, {
...pseudoCollectionOptionsForFiles(trashedFiles),
- id: TRASH_SECTION,
+ id: PseudoCollectionID.trash,
name: t("section_trash"),
type: "trash",
attributes: ["trash"],
@@ -1312,9 +1310,9 @@ const deriveNormalCollectionSummaries = (
const archivedFiles = uniqueFilesByID(
normalFiles.filter((file) => isArchivedFile(file)),
);
- normalCollectionSummaries.set(ARCHIVE_SECTION, {
+ normalCollectionSummaries.set(PseudoCollectionID.archiveItems, {
...pseudoCollectionOptionsForFiles(archivedFiles),
- id: ARCHIVE_SECTION,
+ id: PseudoCollectionID.archiveItems,
name: t("section_archive"),
type: "archive",
attributes: ["archive"],
@@ -1829,7 +1827,7 @@ const deriveAlbumsFilteredFiles = (
const activeCollectionSummaryID = view.activeCollectionSummaryID;
// Trash is dealt with separately.
- if (activeCollectionSummaryID === TRASH_SECTION) {
+ if (activeCollectionSummaryID == PseudoCollectionID.trash) {
return uniqueFilesByID([
...trashedFiles,
...normalFiles.filter((file) => tempDeletedFileIDs.has(file.id)),
@@ -1850,8 +1848,8 @@ const deriveAlbumsFilteredFiles = (
// needs to be before the following (archived collection) case.
if (isArchivedFile(file)) {
return (
- activeCollectionSummaryID === ARCHIVE_SECTION ||
- activeCollectionSummaryID === file.collectionID
+ activeCollectionSummaryID == PseudoCollectionID.archiveItems ||
+ activeCollectionSummaryID == file.collectionID
);
}
diff --git a/web/packages/new/photos/services/collection-summary.ts b/web/packages/new/photos/services/collection-summary.ts
index 4856d4cf19..128657f72b 100644
--- a/web/packages/new/photos/services/collection-summary.ts
+++ b/web/packages/new/photos/services/collection-summary.ts
@@ -72,8 +72,6 @@ export const PseudoCollectionID = {
hiddenItems: -4,
} as const;
-export const ARCHIVE_SECTION = -1;
-export const TRASH_SECTION = -2;
export const HIDDEN_ITEMS_SECTION = -4;
export const ALL_SECTION = 0;
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index 04ce68f645..77bad86265 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -50,8 +50,6 @@ const defaultHiddenCollectionName = ".hidden";
export const defaultHiddenCollectionUserFacingName = "Hidden";
const favoritesCollectionName = "Favorites";
-export const ARCHIVE_SECTION = -1;
-export const TRASH_SECTION = -2;
export const HIDDEN_ITEMS_SECTION = -4;
export const ALL_SECTION = 0;