From 3ab45c2a35044ce036041990665912461aca7304 Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 9 Aug 2013 12:36:17 +0100 Subject: [PATCH] Handle if two updates cancel each other --- services/track-changes/app/coffee/ConversionManager.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/track-changes/app/coffee/ConversionManager.coffee b/services/track-changes/app/coffee/ConversionManager.coffee index d7849818c0..fef745b220 100644 --- a/services/track-changes/app/coffee/ConversionManager.coffee +++ b/services/track-changes/app/coffee/ConversionManager.coffee @@ -40,7 +40,10 @@ module.exports = ConversionManager = compressedUpdates = [lastCompressedUpdate] for rawUpdate in rawUpdates lastCompressedUpdate = compressedUpdates.pop() - compressedUpdates = compressedUpdates.concat ConcatManager.concatTwoUpdates lastCompressedUpdate, rawUpdate + if lastCompressedUpdate? + compressedUpdates = compressedUpdates.concat ConcatManager.concatTwoUpdates lastCompressedUpdate, rawUpdate + else + compressedUpdates.push rawUpdate ConversionManager.removeLatestCompressedUpdate doc_id, (error) -> return callback(error) if error? callback null, compressedUpdates