Skip to content

Commit

Permalink
Data: Migrate post editor persistence with fullscreenMode false (#21082)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth authored and jorgefilipecosta committed Mar 23, 2020
1 parent f22733b commit 7139f58
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions packages/data/src/plugins/persistence/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,26 @@ persistencePlugin.__unstableMigrate = ( pluginOptions ) => {
} );
}

let editPostState = state[ 'core/edit-post' ];

// Default `fullscreenMode` to `false` if any persisted state had existed
// and the user hadn't made an explicit choice about fullscreen mode. This
// is needed since `fullscreenMode` previously did not have a default value
// and was implicitly false by its absence. It is now `true` by default, but
// this change is not intended to affect upgrades from earlier versions.
const hadPersistedState = Object.keys( state ).length > 0;
const hadFullscreenModePreference = has( state, [
'core/edit-post',
'preferences',
'features',
'fullscreenMode',
] );
if ( hadPersistedState && ! hadFullscreenModePreference ) {
editPostState = merge( {}, editPostState, {
preferences: { features: { fullscreenMode: false } },
} );
}

// Migrate 'areTipsEnabled' from 'core/nux' to 'showWelcomeGuide' in 'core/edit-post'
const areTipsEnabled = get( state, [
'core/nux',
Expand All @@ -259,16 +279,17 @@ persistencePlugin.__unstableMigrate = ( pluginOptions ) => {
'welcomeGuide',
] );
if ( areTipsEnabled !== undefined && ! hasWelcomeGuide ) {
persistence.set(
'core/edit-post',
merge( state[ 'core/edit-post' ], {
preferences: {
features: {
welcomeGuide: areTipsEnabled,
},
editPostState = merge( {}, editPostState, {
preferences: {
features: {
welcomeGuide: areTipsEnabled,
},
} )
);
},
} );
}

if ( editPostState !== state[ 'core/edit-post' ] ) {
persistence.set( 'core/edit-post', editPostState );
}
};

Expand Down

0 comments on commit 7139f58

Please sign in to comment.