Skip to content

Commit

Permalink
Merge pull request #291 from adobecom/loading-screen-fix-2
Browse files Browse the repository at this point in the history
[MWPW-161326] Loading Screen on Publish fix
  • Loading branch information
rayyank10 authored Nov 13, 2024
2 parents a2abf52 + 4c2a337 commit 8717d56
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ecc/blocks/form-handler/data-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function getFilteredCachedResponse() {
* @param {*} value2 - The second value to compare.
* @returns {boolean} - Returns true if the values are different, otherwise false.
*/
export function compareObjects(value1, value2) {
export function compareObjects(value1, value2, lengthOnly = false) {
if (
typeof value1 === 'object'
&& value1 !== null
Expand All @@ -93,9 +93,12 @@ export function compareObjects(value1, value2) {
// Change detected due to different array lengths
return true;
}
for (let i = 0; i < value1.length; i += 1) {
if (compareObjects(value1[i], value2[i])) {
return true;

if (!lengthOnly) {
for (let i = 0; i < value1.length; i += 1) {
if (compareObjects(value1[i], value2[i])) {
return true;
}
}
}
} else if (value1 !== value2) {
Expand Down Expand Up @@ -143,7 +146,11 @@ export function hasContentChanged(oldData, newData) {

// Check for differences in the actual values
return oldDataKeys.some(
(key) => key !== 'modificationTime' && compareObjects(oldData[key], newData[key]),
(key) => {
const lengthOnly = key === 'speakers' && !oldData[key].ordinal;

return !ignoreList.includes(key) && compareObjects(oldData[key], newData[key], lengthOnly);
},
);
}

Expand Down

0 comments on commit 8717d56

Please sign in to comment.