@@ -59,7 +59,12 @@ const ProjectSaverHOC = function (WrappedComponent) {
59
59
// but then it'd be hard to turn this listening off in our tests
60
60
window . onbeforeunload = e => this . leavePageConfirm ( e ) ;
61
61
}
62
+
63
+ // Allow the GUI consumer to pass in a function to receive a trigger
64
+ // for triggering thumbnail or whole project saves.
65
+ // These functions are called with null on unmount to prevent stale references.
62
66
this . props . onSetProjectThumbnailer ( this . getProjectThumbnail ) ;
67
+ this . props . onSetProjectSaver ( this . tryToAutoSave ) ;
63
68
}
64
69
componentDidUpdate ( prevProps ) {
65
70
if ( ! this . props . isAnyCreatingNewState && prevProps . isAnyCreatingNewState ) {
@@ -116,6 +121,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
116
121
// window.onbeforeunload = undefined; // eslint-disable-line no-undefined
117
122
// Remove project thumbnailer function since the components are unmounting
118
123
this . props . onSetProjectThumbnailer ( null ) ;
124
+ this . props . onSetProjectSaver ( null ) ;
119
125
}
120
126
leavePageConfirm ( e ) {
121
127
if ( this . props . projectChanged ) {
@@ -310,6 +316,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
310
316
onRemixing,
311
317
onSetProjectUnchanged,
312
318
onSetProjectThumbnailer,
319
+ onSetProjectSaver,
313
320
onShowAlert,
314
321
onShowCopySuccessAlert,
315
322
onShowRemixSuccessAlert,
@@ -376,6 +383,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
376
383
autoSaveIntervalSecs : 120 ,
377
384
onRemixing : ( ) => { } ,
378
385
onSetProjectThumbnailer : ( ) => { } ,
386
+ onSetProjectSaver : ( ) => { } ,
379
387
onUpdateProjectData : saveProjectToServer
380
388
} ;
381
389
const mapStateToProps = ( state , ownProps ) => {
0 commit comments