@@ -4,15 +4,13 @@ import {compose} from 'redux';
44import { connect } from 'react-redux' ;
55import ReactModal from 'react-modal' ;
66import VM from 'scratch-vm' ;
7- import { defineMessages , injectIntl , intlShape } from 'react-intl' ;
7+ import { injectIntl , intlShape } from 'react-intl' ;
88
99import ErrorBoundaryHOC from '../lib/error-boundary-hoc.jsx' ;
1010import {
1111 getIsError ,
12- getIsShowingProject ,
13- getIsShowingWithoutId
12+ getIsShowingProject
1413} from '../reducers/project-state' ;
15- import { setProjectTitle } from '../reducers/project-title' ;
1614import {
1715 activateTab ,
1816 BLOCKS_TAB_INDEX ,
@@ -30,6 +28,7 @@ import {
3028import FontLoaderHOC from '../lib/font-loader-hoc.jsx' ;
3129import LocalizationHOC from '../lib/localization-hoc.jsx' ;
3230import ProjectFetcherHOC from '../lib/project-fetcher-hoc.jsx' ;
31+ import TitledHOC from '../lib/titled-hoc.jsx' ;
3332import ProjectSaverHOC from '../lib/project-saver-hoc.jsx' ;
3433import QueryParserHOC from '../lib/query-parser-hoc.jsx' ;
3534import storage from '../lib/storage' ;
@@ -40,45 +39,21 @@ import cloudManagerHOC from '../lib/cloud-manager-hoc.jsx';
4039import GUIComponent from '../components/gui/gui.jsx' ;
4140import { setIsScratchDesktop } from '../lib/isScratchDesktop.js' ;
4241
43- const messages = defineMessages ( {
44- defaultProjectTitle : {
45- id : 'gui.gui.defaultProjectTitle' ,
46- description : 'Default title for project' ,
47- defaultMessage : 'Scratch Project'
48- }
49- } ) ;
50-
5142class GUI extends React . Component {
5243 componentDidMount ( ) {
5344 setIsScratchDesktop ( this . props . isScratchDesktop ) ;
54- this . setReduxTitle ( this . props . projectTitle ) ;
5545 this . props . onStorageInit ( storage ) ;
5646 this . props . onVmInit ( this . props . vm ) ;
5747 }
5848 componentDidUpdate ( prevProps ) {
5949 if ( this . props . projectId !== prevProps . projectId && this . props . projectId !== null ) {
6050 this . props . onUpdateProjectId ( this . props . projectId ) ;
6151 }
62- if ( this . props . projectTitle !== prevProps . projectTitle ) {
63- this . setReduxTitle ( this . props . projectTitle ) ;
64- }
6552 if ( this . props . isShowingProject && ! prevProps . isShowingProject ) {
6653 // this only notifies container when a project changes from not yet loaded to loaded
6754 // At this time the project view in www doesn't need to know when a project is unloaded
6855 this . props . onProjectLoaded ( ) ;
6956 }
70- if ( this . props . isShowingWithoutId && ! prevProps . isShowingWithoutId ) {
71- this . props . onUpdateProjectTitle ( this . props . intl . formatMessage ( messages . defaultProjectTitle ) ) ;
72- }
73- }
74- setReduxTitle ( newTitle ) {
75- if ( newTitle === null || typeof newTitle === 'undefined' ) {
76- this . props . onUpdateReduxProjectTitle (
77- this . props . intl . formatMessage ( messages . defaultProjectTitle )
78- ) ;
79- } else {
80- this . props . onUpdateReduxProjectTitle ( newTitle ) ;
81- }
8257 }
8358 render ( ) {
8459 if ( this . props . isError ) {
@@ -96,11 +71,9 @@ class GUI extends React.Component {
9671 onProjectLoaded,
9772 onStorageInit,
9873 onUpdateProjectId,
99- onUpdateReduxProjectTitle,
10074 onVmInit,
10175 projectHost,
10276 projectId,
103- projectTitle,
10477 /* eslint-enable no-unused-vars */
10578 children,
10679 fetchingProject,
@@ -137,11 +110,9 @@ GUI.propTypes = {
137110 onStorageInit : PropTypes . func ,
138111 onUpdateProjectId : PropTypes . func ,
139112 onUpdateProjectTitle : PropTypes . func ,
140- onUpdateReduxProjectTitle : PropTypes . func ,
141113 onVmInit : PropTypes . func ,
142114 projectHost : PropTypes . string ,
143115 projectId : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
144- projectTitle : PropTypes . string ,
145116 telemetryModalVisible : PropTypes . bool ,
146117 vm : PropTypes . instanceOf ( VM ) . isRequired
147118} ;
@@ -151,7 +122,6 @@ GUI.defaultProps = {
151122 onStorageInit : storageInstance => storageInstance . addOfficialScratchWebStores ( ) ,
152123 onProjectLoaded : ( ) => { } ,
153124 onUpdateProjectId : ( ) => { } ,
154- onUpdateProjectTitle : ( ) => { } ,
155125 onVmInit : ( /* vm */ ) => { }
156126} ;
157127
@@ -172,7 +142,6 @@ const mapStateToProps = state => {
172142 isPlayerOnly : state . scratchGui . mode . isPlayerOnly ,
173143 isRtl : state . locales . isRtl ,
174144 isShowingProject : getIsShowingProject ( loadingState ) ,
175- isShowingWithoutId : getIsShowingWithoutId ( loadingState ) ,
176145 loadingStateVisible : state . scratchGui . modals . loadingProject ,
177146 projectId : state . scratchGui . projectState . projectId ,
178147 soundsTabVisible : state . scratchGui . editorTab . activeTabIndex === SOUNDS_TAB_INDEX ,
@@ -193,8 +162,7 @@ const mapDispatchToProps = dispatch => ({
193162 onActivateSoundsTab : ( ) => dispatch ( activateTab ( SOUNDS_TAB_INDEX ) ) ,
194163 onRequestCloseBackdropLibrary : ( ) => dispatch ( closeBackdropLibrary ( ) ) ,
195164 onRequestCloseCostumeLibrary : ( ) => dispatch ( closeCostumeLibrary ( ) ) ,
196- onRequestCloseTelemetryModal : ( ) => dispatch ( closeTelemetryModal ( ) ) ,
197- onUpdateReduxProjectTitle : title => dispatch ( setProjectTitle ( title ) )
165+ onRequestCloseTelemetryModal : ( ) => dispatch ( closeTelemetryModal ( ) )
198166} ) ;
199167
200168const ConnectedGUI = injectIntl ( connect (
@@ -211,6 +179,7 @@ const WrappedGui = compose(
211179 FontLoaderHOC ,
212180 QueryParserHOC ,
213181 ProjectFetcherHOC ,
182+ TitledHOC ,
214183 ProjectSaverHOC ,
215184 vmListenerHOC ,
216185 vmManagerHOC ,
0 commit comments