Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(MapView):filtering-hidden-and-archieved-files

Aswin Asok8deceec9ea9d
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
index 6b1986d013..8bfa2313c1 100644
--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
@@ -32,6 +32,8 @@ import {
import type { RemotePullOpts } from "ente-new/photos/components/gallery";
import {
addToFavoritesCollection,
+ isArchivedCollection,
+ isHiddenCollection,
removeFromFavoritesCollection,
} from "ente-new/photos/services/collection";
import { type CollectionSummary } from "ente-new/photos/services/collection-summary";
@@ -776,19 +778,51 @@ function isFileVisible(file: EnteFile): boolean {
/**
* Loads every file stored in IndexedDB, filters those belonging to the
* target collection, removes duplicates by ID, filters out hidden/archived
- * files, and returns the unique set of visible files.
+ * files, and returns the unique set of visible files. For "All", it also
+ * excludes files that belong to hidden or archived collections.
*/
async function getFilesForCollection(
collectionSummary: CollectionSummary,
activeCollection: Collection | undefined,
): Promise<EnteFile[]> {
- const allFiles = await savedCollectionFiles();
- // Filter out hidden and archived files to prevent leaking items users expect to remain hidden
- const visibleFiles = allFiles.filter(isFileVisible);
-
if (collectionSummary.type === "all") {
- return uniqueFilesByID(visibleFiles);
+ const [allFiles, collections] = await Promise.all([
+ savedCollectionFiles(),
+ savedCollections(),
+ ]);
+ // Filter out hidden and archived files to prevent leaking items users expect to remain hidden.
+ const visibleFiles = allFiles.filter(isFileVisible);
+ const hiddenCollectionIDs = new Set(
+ collections
+ .filter(isHiddenCollection)
+ .map((collection) => collection.id),
+ );
+ const archivedCollectionIDs = new Set(
+ collections
+ .filter(isArchivedCollection)
+ .map((collection) => collection.id),
+ );
+ const hiddenFileIDs = new Set(
+ allFiles
+ .filter((file) => hiddenCollectionIDs.has(file.collectionID))
+ .map((file) => file.id),
+ );
+ const archivedFileIDs = new Set(
+ allFiles
+ .filter((file) =>
+ archivedCollectionIDs.has(file.collectionID),
+ )
+ .map((file) => file.id),
+ );
+ const filtered = visibleFiles.filter(
+ (file) =>
+ !hiddenFileIDs.has(file.id) && !archivedFileIDs.has(file.id),
+ );
+ return uniqueFilesByID(filtered);
}
+ const allFiles = await savedCollectionFiles();
+ // Filter out hidden and archived files to prevent leaking items users expect to remain hidden.
+ const visibleFiles = allFiles.filter(isFileVisible);
if (!activeCollection) {
return [];
}
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index fbd549b315..902ca2c677 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -171,7 +171,7 @@
"join_album_and_comment": "Join album and comment",
"like_all": "Like all",
"favorite": "Favorite",
- "remove_favorite": "Unfavorite",
+ "un_favorite": "Unfavorite",
"convert": "Convert",
"multi_folder_upload": "Multiple folders detected",
"upload_to_choice": "Would you like to upload them into",
diff --git a/web/packages/new/photos/components/FileContextMenu.tsx b/web/packages/new/photos/components/FileContextMenu.tsx
index 56e3d86320..24a05bd237 100644
--- a/web/packages/new/photos/components/FileContextMenu.tsx
+++ b/web/packages/new/photos/components/FileContextMenu.tsx
@@ -58,7 +58,7 @@ const actionConfigs: Record<FileContextAction, ActionConfig> = {
fixTime: { label: "fix_creation_time", Icon: ClockIcon },
editLocation: { label: "edit_location", Icon: EditLocationAltIcon },
favorite: { label: "favorite", Icon: StarBorderIcon },
- unfavorite: { label: "remove_favorite", Icon: StarOffIcon },
+ unfavorite: { label: "un_favorite", Icon: StarOffIcon },
archive: { label: "archive", Icon: ArchiveIcon },
unarchive: { label: "unarchive", Icon: UnArchiveIcon },
hide: { label: "hide", Icon: VisibilityOffOutlinedIcon },
diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsx
index 3d1767c1be..cc9ab13d58 100644
--- a/web/packages/new/photos/components/SelectedFileOptions.tsx
+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx
@@ -494,7 +494,7 @@ const FavoriteButton: React.FC<ButtonishProps> = ({ onClick }) => (
);
const UnfavoriteButton: React.FC<ButtonishProps> = ({ onClick }) => (
- <Tooltip title={t("remove_favorite")}>
+ <Tooltip title={t("un_favorite")}>
<IconButton {...{ onClick }}>
<StarOffIcon fontSize="small" />
</IconButton>
diff --git a/web/packages/new/photos/components/icons/StartOffIcon.tsx b/web/packages/new/photos/components/icons/StartOffIcon.tsx
index 2dc2e9093f..16086e5cd1 100644
--- a/web/packages/new/photos/components/icons/StartOffIcon.tsx
+++ b/web/packages/new/photos/components/icons/StartOffIcon.tsx
@@ -2,9 +2,9 @@ import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
import React from "react";
/**
- * Custom star icon (filled).
+ * Custom star-off icon (unfavorite).
*
- * This is the app's custom star shape used for favorites.
+ * This is the app's custom star with a strike-through used to remove favorites.
*/
export const StarOffIcon: React.FC<SvgIconProps> = (props) => (
<SvgIcon {...props} viewBox="0 0 21 20">