Skip to content

Commit 19196c3

Browse files
authored
Merge pull request scratchfoundation#74 from benjiwheeler/manage-title
DesktopHOC manages project title, rather than wrapping with TitledHOC
2 parents 33993cb + 43f7cd5 commit 19196c3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/renderer/app.jsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ const ScratchDesktopHOC = function (WrappedComponent) {
3636
'handleSetTitleFromSave',
3737
'handleStorageInit',
3838
'handleTelemetryModalOptIn',
39-
'handleTelemetryModalOptOut'
39+
'handleTelemetryModalOptOut',
40+
'handleUpdateProjectTitle'
4041
]);
42+
this.state = {
43+
projectTitle: null
44+
};
4145
}
4246
componentDidMount () {
4347
ipcRenderer.on('setTitleFromSave', this.handleSetTitleFromSave);
@@ -52,7 +56,7 @@ const ScratchDesktopHOC = function (WrappedComponent) {
5256
ipcRenderer.send(event, metadata);
5357
}
5458
handleSetTitleFromSave (event, args) {
55-
this.props.onUpdateProjectTitle(args.title);
59+
this.handleUpdateProjectTitle(args.title);
5660
}
5761
handleStorageInit (storageInstance) {
5862
storageInstance.addHelper(new ElectronStorageHelper(storageInstance));
@@ -63,26 +67,28 @@ const ScratchDesktopHOC = function (WrappedComponent) {
6367
handleTelemetryModalOptOut () {
6468
ipcRenderer.send('setTelemetryDidOptIn', false);
6569
}
70+
handleUpdateProjectTitle (newTitle) {
71+
this.setState({projectTitle: newTitle});
72+
}
6673
render () {
6774
const shouldShowTelemetryModal = (typeof ipcRenderer.sendSync('getTelemetryDidOptIn') !== 'boolean');
6875
return (<WrappedComponent
76+
canEditTitle
6977
isScratchDesktop
7078
projectId={defaultProjectId}
79+
projectTitle={this.state.projectTitle}
7180
showTelemetryModal={shouldShowTelemetryModal}
7281
onClickLogo={this.handleClickLogo}
7382
onProjectTelemetryEvent={this.handleProjectTelemetryEvent}
7483
onStorageInit={this.handleStorageInit}
7584
onTelemetryModalOptIn={this.handleTelemetryModalOptIn}
7685
onTelemetryModalOptOut={this.handleTelemetryModalOptOut}
86+
onUpdateProjectTitle={this.handleUpdateProjectTitle}
7787
{...this.props}
7888
/>);
7989
}
8090
}
8191

82-
ScratchDesktopComponent.propTypes = {
83-
onUpdateProjectTitle: PropTypes.func
84-
};
85-
8692
return ScratchDesktopComponent;
8793
};
8894

@@ -91,8 +97,7 @@ const ScratchDesktopHOC = function (WrappedComponent) {
9197
// ability to compose reducers.
9298
const WrappedGui = compose(
9399
AppStateHOC,
94-
TitledHOC,
95-
ScratchDesktopHOC // must come after `TitledHOC` so it has access to `onUpdateProjectTitle`
100+
ScratchDesktopHOC
96101
)(GUI);
97102

98103
ReactDOM.render(<WrappedGui />, appTarget);

0 commit comments

Comments
 (0)