Skip to content

armgit / ente

Public Imported from GitHub
0

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

Merge main and preserve album creation refactor

AswinAsok45f04076b265
diff --cc web/apps/photos/src/components/Collections/AllAlbums.tsx
index cbefc37d4b,fde9996855..876257fdfe
--- a/web/apps/photos/src/components/Collections/AllAlbums.tsx
+++ b/web/apps/photos/src/components/Collections/AllAlbums.tsx
@@@ -51,20 -46,25 +47,12 @@@ import
type SxProps,
type Theme,
} from "@mui/material";
- import { FilledIconButton } from "ente-base/components/mui";
- import { SingleInputDialog } from "ente-base/components/SingleInputDialog";
- import { useModalVisibility } from "ente-base/components/utils/modal";
-import { ensureLocalUser } from "ente-accounts/services/user";
-import { useBaseContext } from "ente-base/context";
import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
import { ItemCard } from "ente-new/photos/components/Tiles";
--import {
- createAlbum,
- createHiddenAlbum,
- deleteCollection,
- isArchivedCollection,
- isDefaultHiddenCollection,
--} from "ente-new/photos/services/collection";
-import {
- isBulkDeletableEmptyAlbum,
- type CollectionsSortBy,
- type CollectionSummary,
+import type {
+ CollectionsSortBy,
+ CollectionSummary,
} from "ente-new/photos/services/collection-summary";
-import {
- savedCollectionFiles,
- savedCollections,
-} from "ente-new/photos/services/photos-fdb";
--import { usePhotosAppContext } from "ente-new/photos/types/context";
import { t } from "i18next";
import memoize from "memoize-one";
import React, { useEffect, useMemo, useRef, useState } from "react";
@@@ -104,15 -106,8 +94,6 @@@ export const AllAlbums: React.FC<AllAlb
const [searchTerm, setSearchTerm] = useState("");
const [albumFilter, setAlbumFilter] = useState<AlbumFilter>("ente");
const showAlbumFilters = !isInHiddenSection && !isInArchiveSection;
- const { showMiniDialog } = useBaseContext();
-- const { showNotification } = usePhotosAppContext();
- const { show: showAlbumNameInput, props: albumNameInputVisibilityProps } =
- useModalVisibility();
- const [albumCreatedToast, setAlbumCreatedToast] = useState<{
- open: boolean;
- albumId?: number;
- albumName?: string;
- }>({ open: false });
-
const handleExited = () => {
setSearchTerm("");
setAlbumFilter("ente");
@@@ -123,32 -118,11 +104,8 @@@
onClose();
};
- const handleCreateAlbum = (albumName: string) => {
- onClose();
-
- void (async () => {
- try {
- const newAlbum = isInHiddenSection
- ? await createHiddenAlbum(albumName)
- : await createAlbum(albumName);
- await onRemotePull();
-
- setAlbumCreatedToast({
- open: true,
- albumId: newAlbum.id,
- albumName: albumName,
- });
- } catch {
- showNotification({
- color: "critical",
- title: t("generic_error_retry"),
- });
- }
- })();
- };
-
- const emptyAlbumCandidates = useMemo(
- () => collectionSummaries.filter(isBulkDeletableEmptyAlbum),
- [collectionSummaries],
- );
- const hasEnoughEmptyAlbums = emptyAlbumCandidates.length >= 3;
+ const { handleDeleteEmptyAlbums, hasEnoughEmptyAlbums } =
+ useDeleteEmptyAlbums(collectionSummaries, onRemotePull);
const showDeleteEmptyAlbums =
showAlbumFilters &&