Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(CollectionHeader):update-error-handling

Aswin Asokc24388dbb2d7
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 0839282c7c..4e0d50a30a 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -188,11 +188,10 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
async ({ name, description }: AlbumDetails) => {
if (!activeCollection) return;
- let didMutate = false;
- let failure: { error: unknown } | undefined;
+ let didAttemptWrite = false;
try {
- if (activeCollection.name.trim() != name) {
- didMutate = true;
+ if (activeCollection.name != name) {
+ didAttemptWrite = true;
await renameCollection(activeCollection, name);
}
if (
@@ -200,25 +199,15 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
activeCollection.pubMagicMetadata?.data.caption ?? ""
).trim() != description
) {
- didMutate = true;
+ didAttemptWrite = true;
await updateCollectionDescription(
activeCollection,
description,
);
}
- } catch (error) {
- failure = { error };
+ } finally {
+ if (didAttemptWrite) void onRemotePull({ silent: true });
}
-
- if (didMutate) {
- try {
- await onRemotePull({ silent: true, strict: true });
- } catch (error) {
- failure ??= { error };
- }
- }
-
- if (failure) throw failure.error;
},
[activeCollection, onRemotePull],
);
diff --git a/web/apps/photos/src/components/Collections/EditAlbumDetailsDialog.tsx b/web/apps/photos/src/components/Collections/EditAlbumDetailsDialog.tsx
index 3cd7aca9a6..5c2f07f304 100644
--- a/web/apps/photos/src/components/Collections/EditAlbumDetailsDialog.tsx
+++ b/web/apps/photos/src/components/Collections/EditAlbumDetailsDialog.tsx
@@ -60,7 +60,7 @@ export const EditAlbumDetailsDialog: React.FC<EditAlbumDetailsDialogProps> = ({
const descriptionLength = albumDescriptionGraphemeCount(trimmedDescription);
const isDescriptionTooLong = descriptionLength > maxAlbumDescriptionLength;
const hasChanges =
- trimmedName != initialName.trim() ||
+ trimmedName != initialName ||
trimmedDescription != initialDescription.trim();
const isSaveDisabled =
!trimmedName ||