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-11-28 05:14:42 -05:00
|
|
|
applyUpdate: (project_id, doc_id, entries = {}, updates = [], track_changes, callback = (error, new_entries) ->) ->
|
|
|
|
{changes, comments} = entries
|
|
|
|
changesTracker = new ChangesTracker(changes, comments)
|
|
|
|
changesTracker.track_changes = track_changes
|
|
|
|
for update in updates
|
|
|
|
for op in update.op
|
|
|
|
changesTracker.applyOp(op, { user_id: update.meta?.user_id, })
|
|
|
|
{changes, comments} = changesTracker
|
|
|
|
callback null, {changes, comments}
|