Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 7913f93

Browse files
committed
Fix AYS showing on page load
1 parent d3166d4 commit 7913f93

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

js/customize-snapshots.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@
565565
snapshot.snapshotEditContainerDisplayed.set( false );
566566

567567
api.state( 'snapshot-saved' ).bind( function( saved ) {
568-
if ( saved ) {
568+
if ( saved && ! snapshot.dirtyEditControlValues ) {
569569
snapshot.updateSnapshotEditControls();
570570
}
571571
} );
@@ -611,6 +611,7 @@
611611
}
612612
snapshot.updatePending = true;
613613
snapshot.editBoxAutoSaveTriggered = true;
614+
snapshot.dirtyEditControlValues = false;
614615
snapshot.updateSnapshot( status ).done( function() {
615616
snapshot.updatePending = snapshot.dirtyEditControlValues;
616617
if ( ! snapshot.updatePending ) {
@@ -621,23 +622,22 @@
621622
snapshot.dirtyEditControlValues = false;
622623
} ).fail( function() {
623624
snapshot.updatePending = false;
625+
snapshot.dirtyEditControlValues = true;
624626
} );
625627
}, delay );
626628

627629
snapshot.editControlSettings( 'title' ).bind( function() {
630+
snapshot.dirtyEditControlValues = true;
628631
if ( ! snapshot.updatePending ) {
629632
update();
630-
} else {
631-
snapshot.dirtyEditControlValues = true;
632633
}
633634
} );
634635

635636
snapshot.editControlSettings( 'date' ).bind( function() {
636637
if ( snapshot.isFutureDate() ) {
638+
snapshot.dirtyEditControlValues = true;
637639
if ( ! snapshot.updatePending ) {
638640
update();
639-
} else {
640-
snapshot.dirtyEditControlValues = true;
641641
}
642642
}
643643
} );
@@ -656,16 +656,13 @@
656656
// @todo Show loader and disable button while auto saving.
657657
api.bind( 'changeset-save', function() {
658658
if ( isValidChangesetStatus() ) {
659-
snapshot.updatePending = true;
660659
snapshot.extendPreviewerQuery();
661660
}
662661
} );
663662

664663
api.bind( 'changeset-saved', function() {
665-
api.state( 'saved' ).set( true ); // Suppress the AYS dialog.
666-
667-
if ( isValidChangesetStatus() ) {
668-
snapshot.updatePending = false;
664+
if ( 'auto-draft' === api.state( 'changesetStatus' ).get() ) {
665+
api.state( 'saved' ).set( true ); // Suppress the AYS dialog.
669666
}
670667
});
671668
},

0 commit comments

Comments
 (0)