Handle if two updates cancel each other

This commit is contained in:
James Allen 2013-08-09 12:36:17 +01:00
parent 54c7959647
commit 3ab45c2a35

View file

@ -40,7 +40,10 @@ module.exports = ConversionManager =
compressedUpdates = [lastCompressedUpdate] compressedUpdates = [lastCompressedUpdate]
for rawUpdate in rawUpdates for rawUpdate in rawUpdates
lastCompressedUpdate = compressedUpdates.pop() lastCompressedUpdate = compressedUpdates.pop()
if lastCompressedUpdate?
compressedUpdates = compressedUpdates.concat ConcatManager.concatTwoUpdates lastCompressedUpdate, rawUpdate compressedUpdates = compressedUpdates.concat ConcatManager.concatTwoUpdates lastCompressedUpdate, rawUpdate
else
compressedUpdates.push rawUpdate
ConversionManager.removeLatestCompressedUpdate doc_id, (error) -> ConversionManager.removeLatestCompressedUpdate doc_id, (error) ->
return callback(error) if error? return callback(error) if error?
callback null, compressedUpdates callback null, compressedUpdates