Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/renderer/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ const ScratchDesktopHOC = function (WrappedComponent) {
'handleSetTitleFromSave',
'handleStorageInit',
'handleTelemetryModalOptIn',
'handleTelemetryModalOptOut'
'handleTelemetryModalOptOut',
'handleUpdateProjectTitle'
]);
this.state = {
projectTitle: null
};
}
componentDidMount () {
ipcRenderer.on('setTitleFromSave', this.handleSetTitleFromSave);
Expand All @@ -52,7 +56,7 @@ const ScratchDesktopHOC = function (WrappedComponent) {
ipcRenderer.send(event, metadata);
}
handleSetTitleFromSave (event, args) {
this.props.onUpdateProjectTitle(args.title);
this.handleUpdateProjectTitle(args.title);
}
handleStorageInit (storageInstance) {
storageInstance.addHelper(new ElectronStorageHelper(storageInstance));
Expand All @@ -63,26 +67,28 @@ const ScratchDesktopHOC = function (WrappedComponent) {
handleTelemetryModalOptOut () {
ipcRenderer.send('setTelemetryDidOptIn', false);
}
handleUpdateProjectTitle (newTitle) {
this.setState({projectTitle: newTitle});
}
render () {
const shouldShowTelemetryModal = (typeof ipcRenderer.sendSync('getTelemetryDidOptIn') !== 'boolean');
return (<WrappedComponent
canEditTitle
isScratchDesktop
projectId={defaultProjectId}
projectTitle={this.state.projectTitle}
showTelemetryModal={shouldShowTelemetryModal}
onClickLogo={this.handleClickLogo}
onProjectTelemetryEvent={this.handleProjectTelemetryEvent}
onStorageInit={this.handleStorageInit}
onTelemetryModalOptIn={this.handleTelemetryModalOptIn}
onTelemetryModalOptOut={this.handleTelemetryModalOptOut}
onUpdateProjectTitle={this.handleUpdateProjectTitle}
{...this.props}
/>);
}
}

ScratchDesktopComponent.propTypes = {
onUpdateProjectTitle: PropTypes.func
};

return ScratchDesktopComponent;
};

Expand All @@ -91,8 +97,7 @@ const ScratchDesktopHOC = function (WrappedComponent) {
// ability to compose reducers.
const WrappedGui = compose(
AppStateHOC,
TitledHOC,
ScratchDesktopHOC // must come after `TitledHOC` so it has access to `onUpdateProjectTitle`
ScratchDesktopHOC
)(GUI);

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