Sort order fix if property path gets updated via multiple start nodes (#3194)

This commit is contained in:
Hetu Nandu 2021-02-24 21:56:00 +05:30 committed by GitHub
parent e197d13399
commit 3944d7e43e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -243,13 +243,27 @@ export default class DataTreeEvaluator {
// Remove duplicates from this list. Since we explicitly walk down the tree and implicitly (by fetching parents) walk
// up the tree, there are bound to be many duplicates.
const uniqueKeysInSortOrder = [...new Set(finalSortOrder)];
const uniqueKeysInSortOrder = new Set(finalSortOrder);
const sortOrderPropertyPaths = Array.from(uniqueKeysInSortOrder);
// if a property path evaluation gets triggered by diff top order changes
// this could lead to incorrect sort order in spite of the bfs traversal
const sortOrderPropertyPaths: string[] = [];
this.sortedDependencies.forEach((path) => {
if (uniqueKeysInSortOrder.has(path)) {
sortOrderPropertyPaths.push(path);
// remove from the uniqueKeysInSortOrder
uniqueKeysInSortOrder.delete(path);
}
});
// Add any remaining paths in the uniqueKeysInSortOrder
const completeSortOrder = [
...Array.from(uniqueKeysInSortOrder),
...sortOrderPropertyPaths,
];
//Trim this list to now remove the property paths which are simply entity names
const finalSortOrderArray: Array<string> = [];
sortOrderPropertyPaths.forEach((propertyPath) => {
completeSortOrder.forEach((propertyPath) => {
const lastIndexOfDot = propertyPath.lastIndexOf(".");
// Only do this for property paths and not the entity themselves
if (lastIndexOfDot !== -1) {