ignore invalid journal entries

This commit is contained in:
Henry Jameson 2022-08-16 19:33:34 +03:00
parent 840ce06397
commit 04acf069d1

View File

@ -132,7 +132,15 @@ export const _mergeFlags = (recent, stale, allFlagKeys) => {
} }
const _mergeJournal = (...journals) => { const _mergeJournal = (...journals) => {
const allJournals = flatten(journals.map(j => Array.isArray(j) ? j : [])) // Ignore invalid journal entries
const allJournals = flatten(
journals.map(j => Array.isArray(j) ? j : [])
).filter(entry =>
Object.prototype.hasOwnProperty.call(entry, 'path') &&
Object.prototype.hasOwnProperty.call(entry, 'operation') &&
Object.prototype.hasOwnProperty.call(entry, 'args') &&
Object.prototype.hasOwnProperty.call(entry, 'timestamp')
)
const grouped = groupBy(allJournals, 'path') const grouped = groupBy(allJournals, 'path')
const trimmedGrouped = Object.entries(grouped).map(([path, journal]) => { const trimmedGrouped = Object.entries(grouped).map(([path, journal]) => {
// side effect // side effect