     -> elt.removeEventListener 'dragstart', listener for elt in elts
   , [folded, history?, message]
 
-  ## Maintain id2dom mapping
+  ## One-time effects
   useEffect ->
+    ## Scroll to this message if it's been requested.
+    if scrollToLater == message._id
+      scrollToLater = null
+      scrollToMessage message._id
+    ## Maintain id2dom mapping, and seed images map
     id2dom[message._id] = ref.current
+    initImage message._id
+    ## initImage calls updateFileQuery which will do this:
+    #images[message._id].file = message.file
+    #initImageInternal message.file if message.file?
     ->
       delete id2dom[message._id]
       checkImage message._id
   , [message._id]
-  ## Scroll to this message if it's been requested.
-  useEffect ->
-    if scrollToLater == message._id
-      scrollToLater = null
-      scrollToMessage message._id
-    undefined
-  , [message._id]
 
   ## Fold naturally folded (minimized and deleted) messages by default on
   ## initial load.  But only if not previously manually overridden.
+  ###
   useEffect ->
     oldDefault = defaultFolded.get message._id
     oldFolded = messageFolded.get message._id

        messageFolded.set message._id, defaultFolded.get message._id
    , 0
  , [message._id]

  ## Fold referenced attached files by default on initial load.
  messageBodyRef = useRef()
  useEffect ->
    initImage message._id
    ## initImage calls updateFileQuery which will do this:
    #images[message._id].file = message.file
    #initImageInternal message.file if message.file?
    ## If message is naturally folded, don't count images it references.
    images[message._id].naturallyFolded = naturallyFolded message
    images[message._id].children = message.children?.length
    return if images[message._id].naturallyFolded
    messageImages = {}
    messageImagesInternal = {}
    return unless messageBodyRef.current?
    for elt in messageBodyRef.current.querySelectorAll """
      img[src^="#{fileUrlPrefix}"],
      img[src^="#{fileAbsoluteUrlPrefix}"],

      initImageInternal id
      imagesInternal[id].count += 1
      checkImageInternal id
    checkImage message._id
    ->
      for id of messageImages
        images[id].count -= 1
