mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2025-01-08 13:41:59 -05:00
ScratchDesktopHOC manages project title, rather than wrapping with TitledHOC
This commit is contained in:
parent
de6a271311
commit
f9e77bc508
1 changed files with 11 additions and 8 deletions
|
@ -36,8 +36,12 @@ const ScratchDesktopHOC = function (WrappedComponent) {
|
|||
'handleSetTitleFromSave',
|
||||
'handleStorageInit',
|
||||
'handleTelemetryModalOptIn',
|
||||
'handleTelemetryModalOptOut'
|
||||
'handleTelemetryModalOptOut',
|
||||
'handleUpdateProjectTitle'
|
||||
]);
|
||||
this.state = {
|
||||
projectTitle: null
|
||||
};
|
||||
}
|
||||
componentDidMount () {
|
||||
ipcRenderer.on('setTitleFromSave', this.handleSetTitleFromSave);
|
||||
|
@ -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));
|
||||
|
@ -63,6 +67,9 @@ 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
|
||||
|
@ -74,15 +81,12 @@ const ScratchDesktopHOC = function (WrappedComponent) {
|
|||
onStorageInit={this.handleStorageInit}
|
||||
onTelemetryModalOptIn={this.handleTelemetryModalOptIn}
|
||||
onTelemetryModalOptOut={this.handleTelemetryModalOptOut}
|
||||
onUpdateProjectTitle={this.handleUpdateProjectTitle}
|
||||
{...this.props}
|
||||
/>);
|
||||
}
|
||||
}
|
||||
|
||||
ScratchDesktopComponent.propTypes = {
|
||||
onUpdateProjectTitle: PropTypes.func
|
||||
};
|
||||
|
||||
return ScratchDesktopComponent;
|
||||
};
|
||||
|
||||
|
@ -91,8 +95,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);
|
||||
|
|
Loading…
Reference in a new issue