From d79a25aa1e062328bbdbc1750efeab15b43cf4b5 Mon Sep 17 00:00:00 2001
From: Christopher Willis-Ford <cwillisf@media.mit.edu>
Date: Wed, 22 Mar 2017 21:17:14 -0700
Subject: [PATCH] Move scratch-storage init/attach from stage to GUI

---
 src/components/gui/gui.jsx | 8 ++++++--
 src/containers/stage.jsx   | 9 +++------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/components/gui/gui.jsx b/src/components/gui/gui.jsx
index 36dbec0e2..4ef85e06f 100644
--- a/src/components/gui/gui.jsx
+++ b/src/components/gui/gui.jsx
@@ -11,6 +11,8 @@ const MenuBar = require('../menu-bar/menu-bar.jsx');
 const Box = require('../box/box.jsx');
 const styles = require('./gui.css');
 
+const Storage = require('../../lib/storage');
+
 const GUIComponent = props => {
     const {
         basePath,
@@ -48,7 +50,7 @@ const GUIComponent = props => {
                             <GreenFlag vm={vm} />
                             <StopAll vm={vm} />
                         </Box>
-                        
+
                         <Box className={styles.stageWrapper} >
                             <Stage
                                 shrink={0}
@@ -74,6 +76,8 @@ GUIComponent.propTypes = {
 };
 GUIComponent.defaultProps = {
     basePath: '/',
-    vm: new VM()
+    vm: new VM(),
+    storage: new Storage()
 };
+GUIComponent.defaultProps.vm.attachStorage(GUIComponent.defaultProps.storage);
 module.exports = GUIComponent;
diff --git a/src/containers/stage.jsx b/src/containers/stage.jsx
index 63d09b05c..3f693b78c 100644
--- a/src/containers/stage.jsx
+++ b/src/containers/stage.jsx
@@ -1,11 +1,10 @@
 const bindAll = require('lodash.bindall');
-const AudioEngine = require('scratch-audio');
 const React = require('react');
 const Renderer = require('scratch-render');
+const AudioEngine = require('scratch-audio');
 const VM = require('scratch-vm');
 
 const StageComponent = require('../components/stage/stage.jsx');
-const Storage = require('../lib/storage');
 
 class Stage extends React.Component {
     constructor (props) {
@@ -33,12 +32,10 @@ class Stage extends React.Component {
         this.attachRectEvents();
         this.attachMouseEvents(this.canvas);
         this.updateRect();
-        this.audioEngine = new AudioEngine();
-        this.props.vm.attachAudioEngine(this.audioEngine);
         this.renderer = new Renderer(this.canvas);
         this.props.vm.attachRenderer(this.renderer);
-        this.storage = new Storage();
-        this.props.vm.attachStorage(this.storage);
+        this.audioEngine = new AudioEngine();
+        this.props.vm.attachAudioEngine(this.audioEngine);
     }
     shouldComponentUpdate () {
         return false;
-- 
GitLab