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:
parent
3257c5720e
commit
d3b07f68a7
2 changed files with 18 additions and 9 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
|
@ -32,4 +32,4 @@ Dockerfile text
|
|||
*.mp4 binary
|
||||
*.svg binary
|
||||
*.csv binary
|
||||
|
||||
*.wav binary
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue