Skip to content
Snippets Groups Projects
Commit 4e38da17 authored by Christopher Willis-Ford's avatar Christopher Willis-Ford
Browse files

Add a hook for custom storage init

parent 4ab73a77
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ import FontLoaderHOC from '../lib/font-loader-hoc.jsx'; ...@@ -29,6 +29,7 @@ import FontLoaderHOC from '../lib/font-loader-hoc.jsx';
import LocalizationHOC from '../lib/localization-hoc.jsx'; import LocalizationHOC from '../lib/localization-hoc.jsx';
import ProjectFetcherHOC from '../lib/project-fetcher-hoc.jsx'; import ProjectFetcherHOC from '../lib/project-fetcher-hoc.jsx';
import ProjectSaverHOC from '../lib/project-saver-hoc.jsx'; import ProjectSaverHOC from '../lib/project-saver-hoc.jsx';
import storage from '../lib/storage';
import vmListenerHOC from '../lib/vm-listener-hoc.jsx'; import vmListenerHOC from '../lib/vm-listener-hoc.jsx';
import vmManagerHOC from '../lib/vm-manager-hoc.jsx'; import vmManagerHOC from '../lib/vm-manager-hoc.jsx';
...@@ -45,6 +46,7 @@ const messages = defineMessages({ ...@@ -45,6 +46,7 @@ const messages = defineMessages({
class GUI extends React.Component { class GUI extends React.Component {
componentDidMount () { componentDidMount () {
this.setReduxTitle(this.props.projectTitle); this.setReduxTitle(this.props.projectTitle);
this.props.onStorageInit(storage);
} }
componentDidUpdate (prevProps) { componentDidUpdate (prevProps) {
if (this.props.projectId !== prevProps.projectId && this.props.projectId !== null) { if (this.props.projectId !== prevProps.projectId && this.props.projectId !== null) {
...@@ -75,6 +77,7 @@ class GUI extends React.Component { ...@@ -75,6 +77,7 @@ class GUI extends React.Component {
hideIntro, hideIntro,
isError, isError,
isShowingProject, isShowingProject,
onStorageInit,
onUpdateProjectId, onUpdateProjectId,
onUpdateReduxProjectTitle, onUpdateReduxProjectTitle,
projectHost, projectHost,
...@@ -111,6 +114,7 @@ GUI.propTypes = { ...@@ -111,6 +114,7 @@ GUI.propTypes = {
isShowingProject: PropTypes.bool, isShowingProject: PropTypes.bool,
loadingStateVisible: PropTypes.bool, loadingStateVisible: PropTypes.bool,
onSeeCommunity: PropTypes.func, onSeeCommunity: PropTypes.func,
onStorageInit: PropTypes.func,
onUpdateProjectId: PropTypes.func, onUpdateProjectId: PropTypes.func,
onUpdateProjectTitle: PropTypes.func, onUpdateProjectTitle: PropTypes.func,
onUpdateReduxProjectTitle: PropTypes.func, onUpdateReduxProjectTitle: PropTypes.func,
...@@ -122,6 +126,7 @@ GUI.propTypes = { ...@@ -122,6 +126,7 @@ GUI.propTypes = {
}; };
GUI.defaultProps = { GUI.defaultProps = {
onStorageInit: storageInstance => storageInstance.addOfficialScratchWebStores(),
onUpdateProjectId: () => {} onUpdateProjectId: () => {}
}; };
......
...@@ -10,6 +10,8 @@ class Storage extends ScratchStorage { ...@@ -10,6 +10,8 @@ class Storage extends ScratchStorage {
constructor () { constructor () {
super(); super();
this.cacheDefaultProject(); this.cacheDefaultProject();
}
addOfficialScratchWebStores () {
this.addWebStore( this.addWebStore(
[this.AssetType.Project], [this.AssetType.Project],
this.getProjectGetConfig.bind(this), this.getProjectGetConfig.bind(this),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment