Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use

Manav Rathif425dc6eafa4
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 483b77be34..8c3fb45c66 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -23,6 +23,7 @@ import {
OverflowMenu,
OverflowMenuOption,
} from "ente-base/components/OverflowMenu";
+import { SingleInputDialog } from "ente-base/components/SingleInputDialog";
import { useModalVisibility } from "ente-base/components/utils/modal";
import { useBaseContext } from "ente-base/context";
import {
@@ -128,7 +129,6 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
setActiveCollectionID,
onCollectionShare,
onCollectionCast,
- setCollectionNamerAttributes,
setFilesDownloadProgressAttributesCreator,
isActiveCollectionDownloadInProgress,
}) => {
@@ -139,6 +139,8 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
const { show: showSortOrderMenu, props: sortOrderMenuVisibilityProps } =
useModalVisibility();
+ const { show: showAlbumNameInput, props: albumNameInputVisibilityProps } =
+ useModalVisibility();
const { type: collectionSummaryType } = collectionSummary;
@@ -165,23 +167,15 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
[showLoadingBar, hideLoadingBar, onGenericError, syncWithRemote],
);
- const showRenameCollectionModal = () => {
- setCollectionNamerAttributes({
- title: t("rename_album"),
- buttonText: t("rename"),
- autoFilledName: activeCollection.name,
- callback: renameCollection,
- });
- };
-
- const _renameCollection = async (newName: string) => {
- if (activeCollection.name !== newName) {
- await CollectionAPI.renameCollection(activeCollection, newName);
- }
- };
-
- const renameCollection = (newName: string) =>
- wrap(() => _renameCollection(newName))();
+ const renameCollection = useCallback(
+ async (newName: string) => {
+ if (activeCollection.name !== newName) {
+ await CollectionAPI.renameCollection(activeCollection, newName);
+ void syncWithRemote(false, true);
+ }
+ },
+ [activeCollection],
+ );
const confirmDeleteCollection = () => {
showMiniDialog({
@@ -403,7 +397,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
menuOptions = [
<OverflowMenuOption
key="rename"
- onClick={showRenameCollectionModal}
+ onClick={showAlbumNameInput}
startIcon={<EditIcon />}
>
{t("rename_album")}
@@ -517,6 +511,15 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
onAscClick={changeSortOrderAsc}
onDescClick={changeSortOrderDesc}
/>
+ <SingleInputDialog
+ {...albumNameInputVisibilityProps}
+ title={t("rename_album")}
+ label={t("enter_album_name")}
+ autoFocus
+ initialValue={activeCollection.name}
+ submitButtonTitle={t("rename")}
+ onSubmit={renameCollection}
+ />
</Box>
);
};