Skip to content

Commit

Permalink
Switch to an await instead of promise then()
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Sep 20, 2023
1 parent 5ab6083 commit fb73520
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/patterns/src/components/create-pattern-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ export default function CreatePatternModal( {
}
}

function onCreate( patternTitle, sync ) {
async function onCreate( patternTitle, sync ) {
// Check that any onBlur save of the categories is completed
// before creating the pattern and closing the modal.
if ( categorySaving ) {
return categorySaving.then( ( newTerms ) => {
addPattern(
patternTitle,
sync,
newTerms.map( ( cat ) => cat.id )
);
} );
const newTerms = await categorySaving;
addPattern(
patternTitle,
sync,
newTerms.map( ( cat ) => cat.id )
);
return;
}
addPattern( patternTitle, sync, categories );
}
Expand Down

0 comments on commit fb73520

Please sign in to comment.