Skip to content
Merged
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
Prev Previous commit
removeTemplate: consider title type
  • Loading branch information
t-hamano committed Jun 29, 2023
commit 5b30f82d632072e4497c053d005100eabbf9a002
9 changes: 8 additions & 1 deletion packages/edit-site/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,18 @@ export const removeTemplate =
throw lastError;
}

// Depending on how the entity was retrieved it's title might be
// an object or simple string.
const templateTitle =
typeof template.title === 'string'
? template.title
: template.title?.rendered;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put ? just in case. This implementation is also done in the following locations:

const templateTitle = typeof title === 'string' ? title : title?.rendered;


registry.dispatch( noticesStore ).createSuccessNotice(
sprintf(
/* translators: The template/part's name. */
__( '"%s" deleted.' ),
decodeEntities( template.title.rendered )
decodeEntities( templateTitle )
),
{ type: 'snackbar', id: 'site-editor-template-deleted-success' }
);
Expand Down