fix: strip milliseconds from date
This commit is contained in:
@@ -37,15 +37,21 @@ module.exports = async function attachEntryState (entry) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// If the field is a single reference we just check if it has pending changes
|
// If the field is a single reference we just check if it has pending changes
|
||||||
} else if (isObject(item[0]) && (!item[0].fields || item[0].sys.updatedAt !== item[1].sys.updatedAt)) {
|
} else if (isObject(item[0]) && (!item[0].fields || !isDateEqual(item[0].sys.updatedAt !== item[1].sys.updatedAt))) {
|
||||||
entry.pendingChanges = true
|
entry.pendingChanges = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// We check if the root element has pending changes
|
// We check if the root element has pending changes
|
||||||
if (entry && publishedEntry && (entry.sys.updatedAt !== publishedEntry.sys.updatedAt)) {
|
if (entry && publishedEntry && (!isDateEqual(entry.sys.updatedAt !== publishedEntry.sys.updatedAt))) {
|
||||||
entry.pendingChanges = true
|
entry.pendingChanges = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry
|
return entry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDateEqual (lhs, rhs) {
|
||||||
|
const lhsDate = new Date(lhs)
|
||||||
|
const rhsDate = new Date(rhs)
|
||||||
|
return lhsDate.setMilliseconds(0) === rhsDate.setMilliseconds(0)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user