π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(photos):replace-all-albums-filter-with-ente
Aswin Asokf14bedad7234
diff --git a/web/apps/photos/src/components/Collections/AllAlbums.tsx b/web/apps/photos/src/components/Collections/AllAlbums.tsxindex 3088657569..a3bb28a117 100644--- a/web/apps/photos/src/components/Collections/AllAlbums.tsx+++ b/web/apps/photos/src/components/Collections/AllAlbums.tsx@@ -109,7 +109,7 @@ export const AllAlbums: React.FC<AllAlbums> = ({}) => {const fullScreen = useMediaQuery(collectionDialogFullScreenQuery);const [searchTerm, setSearchTerm] = useState("");- const [albumFilter, setAlbumFilter] = useState<AlbumFilter>("all");+ const [albumFilter, setAlbumFilter] = useState<AlbumFilter>("ente");const { showMiniDialog } = useBaseContext();const { showNotification } = usePhotosAppContext();const { show: showAlbumNameInput, props: albumNameInputVisibilityProps } =@@ -122,7 +122,7 @@ export const AllAlbums: React.FC<AllAlbums> = ({const handleExited = () => {setSearchTerm("");- setAlbumFilter("all");+ setAlbumFilter("ente");};const onCollectionClick = (collectionID: number) => {@@ -178,7 +178,7 @@ export const AllAlbums: React.FC<AllAlbums> = ({useEffect(() => {if (!visibleAlbumFilters.some(({ value }) => value == albumFilter)) {- setAlbumFilter("all");+ setAlbumFilter("ente");}}, [albumFilter, visibleAlbumFilters]);@@ -268,12 +268,11 @@ export const AllAlbums: React.FC<AllAlbums> = ({};const filteredCollectionSummaries = useMemo(() => {- const albumFilteredCollectionSummaries =- isInHiddenSection || albumFilter == "all"- ? collectionSummaries- : collectionSummaries.filter((cs) =>- matchesAlbumFilter(cs, albumFilter),- );+ const albumFilteredCollectionSummaries = isInHiddenSection+ ? collectionSummaries+ : collectionSummaries.filter((cs) =>+ matchesAlbumFilter(cs, albumFilter),+ );if (!searchTerm.trim()) {return albumFilteredCollectionSummaries;@@ -286,7 +285,7 @@ export const AllAlbums: React.FC<AllAlbums> = ({const showCreateButton = useMemo(() => {if (!canCreateAlbum) return false;- if (!isInHiddenSection && albumFilter != "all") return false;+ if (!isInHiddenSection && albumFilter != "ente") return false;if (!searchTerm.trim()) {return true;}diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsxindex 1fe66a027c..a04eeb60ae 100644--- a/web/apps/photos/src/components/gallery/BarImpl.tsx+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx@@ -95,16 +95,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({"ente",);const visibleAlbumFilters = useMemo(- () =>- getVisibleAlbumFilters(collectionSummaries).map((filter) =>- filter.value == "all"- ? {- value: "ente" as const,- label: () => "Ente",- title: () => "Ente",- }- : filter,- ),+ () => getVisibleAlbumFilters(collectionSummaries),[collectionSummaries],);const activeAlbumFilter =diff --git a/web/apps/photos/src/utils/album-filters.ts b/web/apps/photos/src/utils/album-filters.tsindex d497edd9b1..df768a7e17 100644--- a/web/apps/photos/src/utils/album-filters.ts+++ b/web/apps/photos/src/utils/album-filters.ts@@ -5,14 +5,14 @@ import {import { t } from "i18next";export type AlbumFilter =- "all" | "ente" | "shared" | "received" | "links" | "empty-albums";+ "ente" | "shared" | "received" | "links" | "empty-albums";export const albumFilters: {value: AlbumFilter;label: () => string;title: () => string;}[] = [- { value: "all", label: () => t("all"), title: () => t("all_albums") },+ { value: "ente", label: () => "Ente", title: () => "Ente" },{value: "shared",label: () => t("shared_albums_label"),@@ -40,8 +40,6 @@ export const matchesAlbumFilter = (albumFilter: AlbumFilter,): boolean => {switch (albumFilter) {- case "all":- return true;case "ente":return (!cs.attributes.has("system") &&@@ -72,7 +70,7 @@ export const matchesAlbumFilter = (export const visibleAlbumFilters = (collectionSummaries: CollectionSummary[]) =>albumFilters.filter(({ value }) => {- if (value == "all") return true;+ if (value == "ente") return true;if (value == "empty-albums") {return (collectionSummaries.filter(isBulkDeletableEmptyAlbum).length >=diff --git a/web/apps/photos/tests/album-filters.test.ts b/web/apps/photos/tests/album-filters.test.tsindex 72bf364148..9952d7edde 100644--- a/web/apps/photos/tests/album-filters.test.ts+++ b/web/apps/photos/tests/album-filters.test.ts@@ -67,9 +67,6 @@ describe("album filters shared by the dialog and sidebar", () => {expect(matchesAlbumFilter(albums[12]!, "received")).toBe(true);expect(matchesAlbumFilter(albums[14]!, "shared")).toBe(false);expect(matchesAlbumFilter(albums[15]!, "received")).toBe(false);- expect(- albums.filter((cs) => matchesAlbumFilter(cs, "all")),- ).toHaveLength(16);});test("separates outgoing sharing, incoming sharing, and quick links", () => {@@ -84,7 +81,7 @@ describe("album filters shared by the dialog and sidebar", () => {albums.filter((cs) => matchesAlbumFilter(cs, filter)).map(({ id }) => id);- expect(ids("all")).toEqual([1, 2, 3, 4, 5]);+ expect(ids("ente")).toEqual([1, 2, 3, 4]);expect(ids("shared")).toEqual([2, 4]);expect(ids("received")).toEqual([3]);expect(ids("links")).toEqual([5]);@@ -120,7 +117,7 @@ describe("album filters shared by the dialog and sidebar", () => {album(3, ["shared"], 0),];expect(visibleAlbumFilters(albums).map(({ value }) => value)).toEqual([- "all",+ "ente",]);albums.push(album(4, [], 0),@@ -129,14 +126,14 @@ describe("album filters shared by the dialog and sidebar", () => {album(7, ["quickLink"]),);expect(visibleAlbumFilters(albums).map(({ value }) => value)).toEqual([- "all",+ "ente","shared","received","links","empty-albums",]);expect(visibleAlbumFilters([]).map(({ value }) => value)).toEqual([- "all",+ "ente",]);});});