Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Bindings: Remove "Site Updated" notification for post entity changes #63223

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/editor/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ export const saveDirtyEntities =
close?.( entitiesToSave );
const siteItemsToSave = [];
const pendingSavedRecords = [];
let showSiteUpdatedMessage = false;
entitiesToSave.forEach( ( { kind, name, key, property } ) => {
if ( 'root' === kind && 'site' === name ) {
siteItemsToSave.push( property );
showSiteUpdatedMessage = true;
} else {
if (
PUBLISH_ON_SAVE_ENTITIES.some(
Expand All @@ -176,6 +178,13 @@ export const saveDirtyEntities =
.dispatch( coreStore )
.saveEditedEntityRecord( kind, name, key )
);

// This flag allows us to avoid showing the 'site updated' message
// in scenarios related to entity changes when the message shouldn't be
// triggered, like when modifying post meta via block bindings.
if ( kind !== 'postType' ) {
showSiteUpdatedMessage = true;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, the logic in this code assumed that an entity change must be a site change; this just introduces a flag to circumvent the Site Updated message if the entity change was of kind postType.

I think it works, but I’m not sure this is the most robust solution.

}
} );
if ( siteItemsToSave.length ) {
Expand Down Expand Up @@ -204,7 +213,7 @@ export const saveDirtyEntities =
registry
.dispatch( noticesStore )
.createErrorNotice( __( 'Saving failed.' ) );
} else {
} else if ( showSiteUpdatedMessage ) {
registry
.dispatch( noticesStore )
.createSuccessNotice( __( 'Site updated.' ), {
Expand Down
Loading