From fb735205a6cf0042085f0e0702850696d04e5a27 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 21 Sep 2023 10:54:40 +1200 Subject: [PATCH] Switch to an await instead of promise then() --- .../src/components/create-pattern-modal.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/patterns/src/components/create-pattern-modal.js b/packages/patterns/src/components/create-pattern-modal.js index 817dc1713fd3e..2702e4674cc14 100644 --- a/packages/patterns/src/components/create-pattern-modal.js +++ b/packages/patterns/src/components/create-pattern-modal.js @@ -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 ); }