Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev -> Stage #2 QA Fix #292

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading