Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor(locker):name-unsaved-change-checks

Aswin Asokdf717a6d3dcd
diff --git a/web/apps/locker/src/components/create-item/unsaved-changes.ts b/web/apps/locker/src/components/create-item/unsaved-changes.ts
index 1075602617..92ea6c9e53 100644
--- a/web/apps/locker/src/components/create-item/unsaved-changes.ts
+++ b/web/apps/locker/src/components/create-item/unsaved-changes.ts
@@ -13,14 +13,17 @@ export function hasUnsavedItemChanges(
const collections = new Set(collectionIDs);
const initialCollections = new Set(initialCollectionIDs);
- return (
- collectionName !== "" ||
- [...fields].some(
- (field) => (data[field] ?? "") !== (initialData[field] ?? ""),
- ) ||
+ const hasCollectionDraft = collectionName !== "";
+ const hasFieldChanges = [...fields].some((field) => {
+ const currentValue = data[field] ?? "";
+ const initialValue = initialData[field] ?? "";
+ return currentValue !== initialValue;
+ });
+ const hasCollectionChanges =
collections.size !== initialCollections.size ||
- [...collections].some((id) => !initialCollections.has(id))
- );
+ [...collections].some((id) => !initialCollections.has(id));
+
+ return hasCollectionDraft || hasFieldChanges || hasCollectionChanges;
}
export function hasPendingUploads(