Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mutationObserverCallback(mutationRecords) {
for (const { addedNodes, removedNodes } of mutationRecords) {
const removed = removedNodes.filter(isStatusElement).map(getStatusInternalId)
const added = addedNodes.filter(isStatusElement).map(getStatusInternalId)
const diff = [
...arrayRemove(added, removed).map(getStatusByInternalId(addedNodes)),
...arrayRemove(removed, added).map(getStatusByInternalId(removedNodes)),
]
const loggedInUserStatuses = diff.map(getStatusAuthorId).filter(isLoggedInUserId)
if (isInit) {
isInit = false
return
}
if (loggedInUserStatuses.length) {
refreshStatusCount()
}
}
}
function mutationObserverCallback(mutationRecords) {
for (const { addedNodes, removedNodes } of mutationRecords) {
const removed = removedNodes.filter(isStatusElement).map(getStatusInternalId)
const added = addedNodes.filter(isStatusElement).map(getStatusInternalId)
const diff = [
...arrayRemove(added, removed).map(getStatusByInternalId(addedNodes)),
...arrayRemove(removed, added).map(getStatusByInternalId(removedNodes)),
]
const loggedInUserStatuses = diff.map(getStatusAuthorId).filter(isLoggedInUserId)
if (isInit) {
isInit = false
return
}
if (loggedInUserStatuses.length) {
refreshStatusCount()
}
}
}