     elt.addEventListener 'dragstart', listener for elt in elts
     -> elt.removeEventListener 'dragstart', listener for elt in elts
   , [folded, history?, messageFileRef.current, message]
+
+  ## Maintain id2dom mapping
+  useEffect ->
+    id2dom[message._id] = ref.current
+    -> delete id2dom[message._id]
+  , [message._id, ref.current]
+  ## Scroll to this message if it's been requested.
+  useEffect ->
+    if scrollToLater == message._id
+      scrollToLater = null
+      scrollToMessage message._id
+    undefined
+  , [message._id]
 
   onFold = (e) ->
     e.preventDefault()

  messageFolded.set id, false

Template.submessage.onDestroyed ->
  delete id2template[@data._id]
  checkImage @data._id
  for id of @images ? {}
    if id of images

#Session.setDefault 'images', {}
images = {}
imagesInternal = {}
id2dom = {}
scrollToLater = null
fileQuery = null

