Add a hook for custom storage init

This commit is contained in:
Christopher Willis-Ford committed 2018-10-24 10:39:18 -07:00
1 parent 4ab73a77ee
commit 4e38da17ca
2 files changed
+7

No files matched your search

+5
View File
@@ -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: () => {}
};
+2
View File
@@ -10,6 +10,8 @@ class Storage extends ScratchStorage {
constructor () {
super();
this.cacheDefaultProject();
}
addOfficialScratchWebStores () {
this.addWebStore(
[this.AssetType.Project],
this.getProjectGetConfig.bind(this),