keep telemetry modal state in sync with main process

This commit is contained in:
Christopher Willis-Ford 2020-12-02 14:03:57 -08:00
parent afb29bfdef
commit d56a3c5810

View file

@ -99,15 +99,18 @@ const ScratchDesktopHOC = function (WrappedComponent) {
} }
handleTelemetryModalOptIn () { handleTelemetryModalOptIn () {
ipcRenderer.send('setTelemetryDidOptIn', true); ipcRenderer.send('setTelemetryDidOptIn', true);
this.forceUpdate();
} }
handleTelemetryModalOptOut () { handleTelemetryModalOptOut () {
ipcRenderer.send('setTelemetryDidOptIn', false); ipcRenderer.send('setTelemetryDidOptIn', false);
this.forceUpdate();
} }
handleUpdateProjectTitle (newTitle) { handleUpdateProjectTitle (newTitle) {
this.setState({projectTitle: newTitle}); this.setState({projectTitle: newTitle});
} }
render () { render () {
const shouldShowTelemetryModal = (typeof ipcRenderer.sendSync('getTelemetryDidOptIn') !== 'boolean'); const currentTelemetryState = ipcRenderer.sendSync('getTelemetryDidOptIn');
const shouldShowTelemetryModal = (typeof currentTelemetryState !== 'boolean');
const childProps = omit(this.props, Object.keys(ScratchDesktopComponent.propTypes)); const childProps = omit(this.props, Object.keys(ScratchDesktopComponent.propTypes));
@ -116,6 +119,7 @@ const ScratchDesktopHOC = function (WrappedComponent) {
canModifyCloudData={false} canModifyCloudData={false}
canSave={false} canSave={false}
isScratchDesktop isScratchDesktop
isTelemetryEnabled={currentTelemetryState}
showTelemetryModal={shouldShowTelemetryModal} showTelemetryModal={shouldShowTelemetryModal}
onClickAbout={[ onClickAbout={[
{ {