Skip to content

Commit

Permalink
cancel rewrite findchangeKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
jparez committed Jul 26, 2024
1 parent e099e07 commit 6597c72
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
9 changes: 5 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ const PATHS = {
},
},
DEST: {
BASE: 'dist',
BASE: 'C:\\Users\\bug00\\Downloads\\geny-window\\geny-window',
TEMPLATES: 'dist/templates',
ASSETS: {
CSS: 'dist/css',
CSS: 'C:\\Users\\bug00\\Downloads\\geny-window\\geny-window',
},
LIB: {
JS: 'dist/js',
CSS: 'dist/css',
JS: 'C:\\Users\\bug00\\Downloads\\geny-window\\geny-window',
//JS: 'D:\\developpement\\GenyMobile\\genymotion-cloud-fe-saas-webapp\\node_modules\\@genymotion\\device-web-player\\dist\\js',
CSS: 'C:\\Users\\bug00\\Downloads\\geny-window\\geny-window',
},
},
TEST: {
Expand Down
35 changes: 18 additions & 17 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,39 @@ const createStore = (instance, reducer) => {
});
};

const arraysAreEqual = (firstArray, secondArray) => {
if (firstArray.length !== secondArray.length) {
return true;
}
for (let i = 0; i < firstArray.length; i++) {
if (firstArray[i] !== secondArray[i]) {
return true;
}
}
return false;
};
const findChangedKeys = (newState, oldState, path = []) => {
let changedKeys = [];

const isObject = (obj) => obj && typeof obj === 'object';

for (const key in newState) {
const fullPath = [...path, key].join('.');

if (!Object.prototype.hasOwnProperty.call(oldState, key)) {
changedKeys.push(fullPath);
} else if (isObject(newState[key]) && isObject(oldState[key])) {
if (
Array.isArray(newState[key]) &&
Array.isArray(oldState[key]) &&
!arraysAreEqual(newState[key], oldState[key])
) {
changedKeys.push(fullPath);
if (Array.isArray(newState[key]) && Array.isArray(oldState[key])) {
if (newState[key].length !== oldState[key].length) {
changedKeys.push(fullPath);
} else {
let arrayHasChanged = false;
for (let i = 0; i < newState[key].length; i++) {
if (newState[key][i] !== oldState[key][i]) {
arrayHasChanged = true;
}
}
if (arrayHasChanged) {
changedKeys.push(fullPath);
}
}
} else {
changedKeys = changedKeys.concat(findChangedKeys(newState[key], oldState[key], [...path, key]));
}
} else if (newState[key] !== oldState[key]) {
changedKeys.push(fullPath);
}
}

return changedKeys;
};

Expand Down

0 comments on commit 6597c72

Please sign in to comment.