2016-11-28 05:14:42 -05:00
|
|
|
ChangesTracker = require "./ChangesTracker"
|
2014-02-26 10:56:52 -05:00
|
|
|
|
2014-02-28 13:29:05 -05:00
|
|
|
module.exports = TrackChangesManager =
|
2016-12-02 06:04:21 -05:00
|
|
|
applyUpdate: (project_id, doc_id, entries = {}, updates = [], callback = (error, new_entries) ->) ->
|
2016-11-28 05:14:42 -05:00
|
|
|
{changes, comments} = entries
|
|
|
|
changesTracker = new ChangesTracker(changes, comments)
|
|
|
|
for update in updates
|
2016-12-02 06:04:21 -05:00
|
|
|
changesTracker.track_changes = !!update.meta.tc
|
2016-11-28 05:14:42 -05:00
|
|
|
for op in update.op
|
2016-12-02 06:04:21 -05:00
|
|
|
changesTracker.applyOp(op, { user_id: update.meta?.user_id })
|
2016-11-28 05:14:42 -05:00
|
|
|
{changes, comments} = changesTracker
|
|
|
|
callback null, {changes, comments}
|