From 4e38da17cae3906f5d1a9cf1859f5f34ffa826be Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <cwillisf@media.mit.edu> Date: Mon, 22 Oct 2018 18:43:21 -0700 Subject: [PATCH] Add a hook for custom storage init --- src/containers/gui.jsx | 5 +++++ src/lib/storage.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/containers/gui.jsx b/src/containers/gui.jsx index e7766cf7a..3146e55a5 100644 --- a/src/containers/gui.jsx +++ b/src/containers/gui.jsx @@ -29,6 +29,7 @@ import FontLoaderHOC from '../lib/font-loader-hoc.jsx'; import LocalizationHOC from '../lib/localization-hoc.jsx'; import ProjectFetcherHOC from '../lib/project-fetcher-hoc.jsx'; import ProjectSaverHOC from '../lib/project-saver-hoc.jsx'; +import storage from '../lib/storage'; import vmListenerHOC from '../lib/vm-listener-hoc.jsx'; import vmManagerHOC from '../lib/vm-manager-hoc.jsx'; @@ -45,6 +46,7 @@ const messages = defineMessages({ class GUI extends React.Component { componentDidMount () { this.setReduxTitle(this.props.projectTitle); + this.props.onStorageInit(storage); } componentDidUpdate (prevProps) { if (this.props.projectId !== prevProps.projectId && this.props.projectId !== null) { @@ -75,6 +77,7 @@ class GUI extends React.Component { hideIntro, isError, isShowingProject, + onStorageInit, onUpdateProjectId, onUpdateReduxProjectTitle, projectHost, @@ -111,6 +114,7 @@ GUI.propTypes = { isShowingProject: PropTypes.bool, loadingStateVisible: PropTypes.bool, onSeeCommunity: PropTypes.func, + onStorageInit: PropTypes.func, onUpdateProjectId: PropTypes.func, onUpdateProjectTitle: PropTypes.func, onUpdateReduxProjectTitle: PropTypes.func, @@ -122,6 +126,7 @@ GUI.propTypes = { }; GUI.defaultProps = { + onStorageInit: storageInstance => storageInstance.addOfficialScratchWebStores(), onUpdateProjectId: () => {} }; diff --git a/src/lib/storage.js b/src/lib/storage.js index b0634d9c3..546de16ec 100644 --- a/src/lib/storage.js +++ b/src/lib/storage.js @@ -10,6 +10,8 @@ class Storage extends ScratchStorage { constructor () { super(); this.cacheDefaultProject(); + } + addOfficialScratchWebStores () { this.addWebStore( [this.AssetType.Project], this.getProjectGetConfig.bind(this), -- GitLab