Customize: Ensure autosave revision is dismissed immediately after implicit restoration notice dismissal as done with explicit notice dismissal.
Fixes issue where a drafted/scheduled changeset could inadvertently re-use the previous autosave revision in the preview while a user expects it to have been dismissed. See #39896, [41597]. Fixes #42502 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@42144 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
605505e9f7
commit
89bea84d6e
|
@ -8248,7 +8248,7 @@
|
|||
|
||||
// Set up initial notifications.
|
||||
(function() {
|
||||
var removedQueryParams = [];
|
||||
var removedQueryParams = [], autosaveDismissed = false;
|
||||
|
||||
/**
|
||||
* Obtain the URL to restore the autosave.
|
||||
|
@ -8294,6 +8294,25 @@
|
|||
history.replaceState( {}, document.title, urlParser.href );
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss autosave.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function dismissAutosave() {
|
||||
if ( autosaveDismissed ) {
|
||||
return;
|
||||
}
|
||||
wp.ajax.post( 'customize_dismiss_autosave_or_lock', {
|
||||
wp_customize: 'on',
|
||||
customize_theme: api.settings.theme.stylesheet,
|
||||
customize_changeset_uuid: api.settings.changeset.uuid,
|
||||
nonce: api.settings.nonce.dismiss_autosave_or_lock,
|
||||
dismiss_autosave: true
|
||||
} );
|
||||
autosaveDismissed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add notification regarding the availability of an autosave to restore.
|
||||
*
|
||||
|
@ -8319,15 +8338,7 @@
|
|||
} );
|
||||
|
||||
// Handle dismissal of notice.
|
||||
li.find( '.notice-dismiss' ).on( 'click', function() {
|
||||
wp.ajax.post( 'customize_dismiss_autosave_or_lock', {
|
||||
wp_customize: 'on',
|
||||
customize_theme: api.settings.theme.stylesheet,
|
||||
customize_changeset_uuid: api.settings.changeset.uuid,
|
||||
nonce: api.settings.nonce.dismiss_autosave_or_lock,
|
||||
dismiss_autosave: true
|
||||
} );
|
||||
} );
|
||||
li.find( '.notice-dismiss' ).on( 'click', dismissAutosave );
|
||||
|
||||
return li;
|
||||
}
|
||||
|
@ -8335,6 +8346,7 @@
|
|||
|
||||
// Remove the notification once the user starts making changes.
|
||||
onStateChange = function() {
|
||||
dismissAutosave();
|
||||
api.notifications.remove( code );
|
||||
api.unbind( 'change', onStateChange );
|
||||
api.state( 'changesetStatus' ).unbind( onStateChange );
|
||||
|
|
Loading…
Reference in New Issue