Fix changed detection

This commit is contained in:
2020-04-03 15:25:05 -05:00
parent 84449347b4
commit 1144dbe81c

View File

@@ -27,11 +27,21 @@ class Configuration extends IPCContainer {
Template: {} Template: {}
}; };
checkItemChanged = (itemA, itemB) => {
if (itemA.type === 'string_array') {
if (itemA.value.length !== itemB.value.length) {
return true;
}
return itemA.value.filter(i => !itemB.value.includes(i)).length !== 0;
}
return itemA.value !== itemB.value;
};
checkSaveRequired = () => { checkSaveRequired = () => {
const changedItems = []; const changedItems = [];
let i = 0; let i = 0;
for (const item of this.state.ItemList) { for (const item of this.state.ItemList) {
if (this.state.OriginalItemList[i++].value !== item.value) { if (this.checkItemChanged(this.state.OriginalItemList[i++], item)) {
changedItems.push(item); changedItems.push(item);
} }
} }
@@ -41,7 +51,7 @@ class Configuration extends IPCContainer {
const changedObjectItems = []; const changedObjectItems = [];
let j = 0; let j = 0;
for (const item of this.state.ObjectLookup[key]) { for (const item of this.state.ObjectLookup[key]) {
if (this.state.OriginalObjectLookup[key][j++].value !== item.value) { if (this.checkItemChanged(this.state.OriginalObjectLookup[key][j++], item)) {
changedObjectItems.push(item); changedObjectItems.push(item);
} }
} }