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
|
*.mp4 binary
|
||||||
*.svg binary
|
*.svg binary
|
||||||
*.csv binary
|
*.csv binary
|
||||||
|
*.wav binary
|
||||||
|
|
|
||||||
|
|
@ -51,24 +51,19 @@ export default function UpdateAllComponents({}: {}) {
|
||||||
title: ERROR_MESSAGE_EDGES_LOST,
|
title: ERROR_MESSAGE_EDGES_LOST,
|
||||||
});
|
});
|
||||||
|
|
||||||
edgesUpdateRef.current = {
|
resetEdgesUpdateRef();
|
||||||
numberOfEdgesBeforeUpdate: 0,
|
|
||||||
updateComponent: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}, [edges]);
|
}, [edges]);
|
||||||
|
|
||||||
const getSuccessTitle = (updatedCount: number) => {
|
const getSuccessTitle = (updatedCount: number) => {
|
||||||
|
resetEdgesUpdateRef();
|
||||||
return `Successfully updated ${updatedCount} component${
|
return `Successfully updated ${updatedCount} component${
|
||||||
updatedCount > 1 ? "s" : ""
|
updatedCount > 1 ? "s" : ""
|
||||||
}`;
|
}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateAllComponents = () => {
|
const handleUpdateAllComponents = () => {
|
||||||
edgesUpdateRef.current = {
|
startEdgesUpdateRef();
|
||||||
numberOfEdgesBeforeUpdate: edges.length,
|
|
||||||
updateComponent: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
setLoadingUpdate(true);
|
setLoadingUpdate(true);
|
||||||
takeSnapshot();
|
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;
|
if (componentsToUpdate.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue