fire subdocs event only when something changed
This commit is contained in:
parent
f915ebda1b
commit
3586d91925
@ -350,11 +350,13 @@ const cleanupTransactions = (transactionCleanups, i) => {
|
|||||||
doc.emit('updateV2', [encoder.toUint8Array(), transaction.origin, doc, transaction])
|
doc.emit('updateV2', [encoder.toUint8Array(), transaction.origin, doc, transaction])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transaction.subdocsAdded.forEach(subdoc => doc.subdocs.add(subdoc))
|
const { subdocsAdded, subdocsLoaded, subdocsRemoved } = transaction
|
||||||
transaction.subdocsRemoved.forEach(subdoc => doc.subdocs.delete(subdoc))
|
if (subdocsAdded.size > 0 || subdocsRemoved.size > 0 || subdocsLoaded.size > 0) {
|
||||||
|
subdocsAdded.forEach(subdoc => doc.subdocs.add(subdoc))
|
||||||
doc.emit('subdocs', [{ loaded: transaction.subdocsLoaded, added: transaction.subdocsAdded, removed: transaction.subdocsRemoved }])
|
subdocsRemoved.forEach(subdoc => doc.subdocs.delete(subdoc))
|
||||||
transaction.subdocsRemoved.forEach(subdoc => subdoc.destroy())
|
doc.emit('subdocs', [{ loaded: subdocsLoaded, added: subdocsAdded, removed: subdocsRemoved }])
|
||||||
|
subdocsRemoved.forEach(subdoc => subdoc.destroy())
|
||||||
|
}
|
||||||
|
|
||||||
if (transactionCleanups.length <= i + 1) {
|
if (transactionCleanups.length <= i + 1) {
|
||||||
doc._transactionCleanups = []
|
doc._transactionCleanups = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user