Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ export const ExperimentalEditorProvider = withRegistryProvider(
setEditedPost,
setRenderingMode,
} = unlock( useDispatch( editorStore ) );
const { createWarningNotice } = useDispatch( noticesStore );
const { createWarningNotice, removeNotice } =
useDispatch( noticesStore );

// Ideally this should be synced on each change and not just something you do once.
useLayoutEffect( () => {
Expand Down Expand Up @@ -321,7 +322,9 @@ export const ExperimentalEditorProvider = withRegistryProvider(
// Synchronizes the active post with the state
useEffect( () => {
setEditedPost( post.type, post.id );
}, [ post.type, post.id, setEditedPost ] );
// Clear any notices dependent and the post context.
removeNotice( 'template-activate-notice' );
}, [ post.type, post.id, setEditedPost, removeNotice ] );

// Synchronize the editor settings as they change.
useEffect( () => {
Expand Down
19 changes: 5 additions & 14 deletions packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,12 @@ async function templateActivationNotice( { select, registry } ) {
{
label: __( 'Activate' ),
onClick: async () => {
await registry
.dispatch( noticesStore )
.removeNotice( 'template-activate-notice' );
await registry
.dispatch( noticesStore )
.createNotice(
'info',
__( 'Activating template…' ),
{
id: 'template-activating-notice',
}
{ id: 'template-activate-notice' }
);
try {
const currentSite = await registry
Expand All @@ -376,22 +371,18 @@ async function templateActivationNotice( { select, registry } ) {
},
{ throwOnError: true }
);
await registry
.dispatch( noticesStore )
.removeNotice( 'template-activating-notice' );
await registry
.dispatch( noticesStore )
.createSuccessNotice(
__( 'Template activated.' )
__( 'Template activated.' ),
{ id: 'template-activate-notice' }
);
} catch ( error ) {
await registry
.dispatch( noticesStore )
.removeNotice( 'template-activating-notice' );
await registry
.dispatch( noticesStore )
.createErrorNotice(
__( 'Template activation failed.' )
__( 'Template activation failed.' ),
{ id: 'template-activate-notice' }
);
// Rethrow for debugging.
throw error;
Expand Down
Loading