     unless nextProps.tutorial is @props.tutorial
       @fetchMediaFor nextProps.tutorial
 
-  fetchMediaFor: (tutorial) ->
-    tutorial.get 'attached_images', {}
-      .then (mediaResources) =>
-        mediaByID = {}
-        for mediaResource in mediaResources
-          mediaByID[mediaResource.id] = mediaResource
-        @setState media: mediaByID
-
   render: ->
     <TutorialEditor
       tutorial={@props.tutorial}
-      media={@state.media}
-      onStepAdd={@handleAddStep}
+      media={@props.media}
+      onStepAdd={@handleStepAdd}
       onStepRemove={@handleStepRemove}
       onMediaSelect={@handleStepMediaChange}
       onMediaClear={@handleStepMediaClear}
       onStepChange={@handleStepChange}
     />
 
-  handleAddStep: ->
+  handleStepAdd: ->
     @props.tutorial.steps.push
       media: ''
       content: ''


  render: ->
    <div>
      <p>This project doesn’t have a tutorial yet.</p>
      {if @state.error?
          <p>{@state.error.toString()}</p>}
      <p>

      loading: true
      error: null
      tutorial: null
    apiClient.type('tutorials').get project_id: project.id
      .then ([tutorial]) =>
        @fetchMediaFor tutorial
        @setState {tutorial}
      .catch (error) =>
        @setState {error}
      .then =>
        @setState loading: false

  fetchMediaFor: (tutorial) ->
    tutorial.get 'attached_images', {} # Prevent caching.
      .then (mediaResources) =>
        media = {}
        for mediaResource in mediaResources
          media[mediaResource.id] = mediaResource
        @setState {media}

  render: ->
    if @state.loading
