fix: Can't enable a partition key after disable it (#4507)

this PR can fix the issue with #4487 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Enhanced logic for filtering keys in the stream comparison, allowing
for more nuanced handling of disabled items.
- **Bug Fixes**
- Improved management of the `remove` array to ensure proper retention
of items based on their presence in the `add` array.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Sai Nikhil
2024-09-10 16:22:33 +05:30
committed by GitHub
parent 6352ba276a
commit b5e377296a
+9 -4
View File
@@ -453,8 +453,8 @@ const useStreams = () => {
return objA === objB;
}
const keysA = Object.keys(objA).filter((key: string) => key !== "disabled");
const keysB = Object.keys(objB).filter((key: string) => key !== "disabled");
const keysA = Object.keys(objA)
const keysB = Object.keys(objB)
if (keysA.length !== keysB.length) return false;
@@ -517,8 +517,13 @@ const useStreams = () => {
const result: any = compareArrays(previousArray, currentArray);
add = result.add;
remove = result.remove;
remove = remove.filter((item: any) => item.disabled !== true);
remove = remove.filter((item: any) => {
const isInAdd = add.some((addItem: any) => addItem.field === item.field);
// Only keep in `remove` if not in `add` and `disabled` is false
return !isInAdd && item.disabled === false;
});
} else {
// For other attributes, do a simple array comparison
add = currentArray.filter((item: any) => !previousArray.includes(item));