Skip to content

The open alternative to Salesforce, designed for AI.

fix(metadata-store): adopt new collection hash on replaceDraft when data is unchanged (#28412)

Mahmoud Ghazyc13b414b7a5a
diff --git a/packages/twenty-front/src/modules/metadata-store/hooks/useUpdateMetadataStoreDraft.ts b/packages/twenty-front/src/modules/metadata-store/hooks/useUpdateMetadataStoreDraft.ts
index bdc8aa330cf..bc06525b04c 100644
--- a/packages/twenty-front/src/modules/metadata-store/hooks/useUpdateMetadataStoreDraft.ts
+++ b/packages/twenty-front/src/modules/metadata-store/hooks/useUpdateMetadataStoreDraft.ts
@@ -60,6 +60,18 @@ export const useUpdateMetadataStoreDraft = () => {
currentEntry.status === 'up-to-date' &&
isDeeplyEqual(currentEntry.current, data)
) {
+ if (
+ isDefined(currentEntry.draftCollectionHash) &&
+ currentEntry.draftCollectionHash !==
+ currentEntry.currentCollectionHash
+ ) {
+ store.set(metadataStoreState.atomFamily(key), {
+ ...currentEntry,
+ currentCollectionHash: currentEntry.draftCollectionHash,
+ draftCollectionHash: undefined,
+ });
+ }
+
return;
}