   else
     message
 
+@findLastDiff = (id) ->
+  MessagesDiff.find
+    id: id
+  ,
+    sort: updated: -1
+    limit: 1
+  .fetch()?[0]
+
 @messageEmpty = (message) ->
   message = findMessage message
   message.title.trim().length == 0 and

        Meteor.clearTimeout stopTimers[id]
        editor2messageUpdate id, [Meteor.user().username]
        ShareJS.model.delete id
      ## xxx should add to last MessagesDiff (possibly just made) that
      ## Meteor.user().username just committed this version.

  messageImport: (group, parent, message, diffs) ->
    #check Meteor.userId(), String  ## should be done by 'canImport'

    Meteor.clearTimeout stopTimers[id]
    stopTimers[id] = Meteor.setTimeout ->
      ## This code is like an extreme form of `messageEditStop` below:
      editing = Messages.findOne(id).editing ? []
      editor2messageUpdate id, editing
      Messages.update id,
        $set: editing: []
      lastDiff = findLastDiff id
      relevant = (editor for editor in editing when editor in (lastDiff?.updators ? []))
      if relevant.length
        MessagesDiff.update lastDiff._id,
          $addToSet: finished: $each: relevant
      ShareJS.model.delete id
    , idleStop

