@@ -36,8 +36,12 @@ const ScratchDesktopHOC = function (WrappedComponent) {
36
36
'handleSetTitleFromSave' ,
37
37
'handleStorageInit' ,
38
38
'handleTelemetryModalOptIn' ,
39
- 'handleTelemetryModalOptOut'
39
+ 'handleTelemetryModalOptOut' ,
40
+ 'handleUpdateProjectTitle'
40
41
] ) ;
42
+ this . state = {
43
+ projectTitle : null
44
+ } ;
41
45
}
42
46
componentDidMount ( ) {
43
47
ipcRenderer . on ( 'setTitleFromSave' , this . handleSetTitleFromSave ) ;
@@ -52,7 +56,7 @@ const ScratchDesktopHOC = function (WrappedComponent) {
52
56
ipcRenderer . send ( event , metadata ) ;
53
57
}
54
58
handleSetTitleFromSave ( event , args ) {
55
- this . props . onUpdateProjectTitle ( args . title ) ;
59
+ this . handleUpdateProjectTitle ( args . title ) ;
56
60
}
57
61
handleStorageInit ( storageInstance ) {
58
62
storageInstance . addHelper ( new ElectronStorageHelper ( storageInstance ) ) ;
@@ -63,26 +67,28 @@ const ScratchDesktopHOC = function (WrappedComponent) {
63
67
handleTelemetryModalOptOut ( ) {
64
68
ipcRenderer . send ( 'setTelemetryDidOptIn' , false ) ;
65
69
}
70
+ handleUpdateProjectTitle ( newTitle ) {
71
+ this . setState ( { projectTitle : newTitle } ) ;
72
+ }
66
73
render ( ) {
67
74
const shouldShowTelemetryModal = ( typeof ipcRenderer . sendSync ( 'getTelemetryDidOptIn' ) !== 'boolean' ) ;
68
75
return ( < WrappedComponent
76
+ canEditTitle
69
77
isScratchDesktop
70
78
projectId = { defaultProjectId }
79
+ projectTitle = { this . state . projectTitle }
71
80
showTelemetryModal = { shouldShowTelemetryModal }
72
81
onClickLogo = { this . handleClickLogo }
73
82
onProjectTelemetryEvent = { this . handleProjectTelemetryEvent }
74
83
onStorageInit = { this . handleStorageInit }
75
84
onTelemetryModalOptIn = { this . handleTelemetryModalOptIn }
76
85
onTelemetryModalOptOut = { this . handleTelemetryModalOptOut }
86
+ onUpdateProjectTitle = { this . handleUpdateProjectTitle }
77
87
{ ...this . props }
78
88
/> ) ;
79
89
}
80
90
}
81
91
82
- ScratchDesktopComponent . propTypes = {
83
- onUpdateProjectTitle : PropTypes . func
84
- } ;
85
-
86
92
return ScratchDesktopComponent ;
87
93
} ;
88
94
@@ -91,8 +97,7 @@ const ScratchDesktopHOC = function (WrappedComponent) {
91
97
// ability to compose reducers.
92
98
const WrappedGui = compose (
93
99
AppStateHOC ,
94
- TitledHOC ,
95
- ScratchDesktopHOC // must come after `TitledHOC` so it has access to `onUpdateProjectTitle`
100
+ ScratchDesktopHOC
96
101
) ( GUI ) ;
97
102
98
103
ReactDOM . render ( < WrappedGui /> , appTarget ) ;
0 commit comments