Fix: Reset Edge Update Tracking Before Success Message in UpdateAllComponents (#6797)

🔧 (.gitattributes): mark *.wav files as binary to prevent line ending conversions
♻️ (UpdateAllComponents/index.tsx): refactor code to use separate functions for resetting and starting edges update reference to improve readability and maintainability
This commit is contained in:
Cristhian Zanforlin Lousa 2025-02-24 20:04:59 -03:00 committed by GitHub
commit d3b07f68a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 9 deletions

2
.gitattributes vendored
View file

@ -32,4 +32,4 @@ Dockerfile text
*.mp4 binary
*.svg binary
*.csv binary
*.wav binary

View file

@ -51,24 +51,19 @@ export default function UpdateAllComponents({}: {}) {
title: ERROR_MESSAGE_EDGES_LOST,
});
edgesUpdateRef.current = {
numberOfEdgesBeforeUpdate: 0,
updateComponent: false,
};
resetEdgesUpdateRef();
}
}, [edges]);
const getSuccessTitle = (updatedCount: number) => {
resetEdgesUpdateRef();
return `Successfully updated ${updatedCount} component${
updatedCount > 1 ? "s" : ""
}`;
};
const handleUpdateAllComponents = () => {
edgesUpdateRef.current = {
numberOfEdgesBeforeUpdate: edges.length,
updateComponent: true,
};
startEdgesUpdateRef();
setLoadingUpdate(true);
takeSnapshot();
@ -135,6 +130,20 @@ export default function UpdateAllComponents({}: {}) {
});
};
const resetEdgesUpdateRef = () => {
edgesUpdateRef.current = {
numberOfEdgesBeforeUpdate: 0,
updateComponent: false,
};
};
const startEdgesUpdateRef = () => {
edgesUpdateRef.current = {
numberOfEdgesBeforeUpdate: edges.length,
updateComponent: true,
};
};
if (componentsToUpdate.length === 0) return null;
return (