From d73b5d5830ec3413eaf37a243e13681af16883c5 Mon Sep 17 00:00:00 2001 From: MarkovSergii Date: Thu, 19 Jul 2018 09:54:55 +0300 Subject: [PATCH] fix type conflict --- common/models/change.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/common/models/change.js b/common/models/change.js index 246a36c5..169ad253 100644 --- a/common/models/change.js +++ b/common/models/change.js @@ -799,16 +799,23 @@ module.exports = function(Change) { Conflict.prototype.type = function(cb) { var conflict = this; this.changes(function(err, sourceChange, targetChange) { - if (err) return cb(err); - var sourceChangeType = sourceChange.type(); - var targetChangeType = targetChange.type(); - if (sourceChangeType === Change.UPDATE && targetChangeType === Change.UPDATE) { - return cb(null, Change.UPDATE); + + if (err) return cb(err) + + if (sourceChange && targetChange) { + var sourceChangeType = sourceChange.type() + var targetChangeType = targetChange.type() + if (sourceChangeType === 'update' && targetChangeType === 'update') { + return cb(null, 'update') + } + if (sourceChangeType === 'delete' || targetChangeType === 'delete') { + return cb(null, 'delete') + } } - if (sourceChangeType === Change.DELETE || targetChangeType === Change.DELETE) { - return cb(null, Change.DELETE); - } - return cb(null, Change.UNKNOWN); + + return cb(null, 'unknown') + + }); }; };