From f979041a81d2df5d5ae5a4bd6cc05525f87a353a Mon Sep 17 00:00:00 2001 From: Markus Dobmann Date: Mon, 6 Mar 2023 13:13:04 +0100 Subject: [PATCH] clean up a little --- packages/components/src/query-controls/terms.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/components/src/query-controls/terms.ts b/packages/components/src/query-controls/terms.ts index 26df5357e895cc..951ca626bee0f3 100644 --- a/packages/components/src/query-controls/terms.ts +++ b/packages/components/src/query-controls/terms.ts @@ -22,14 +22,12 @@ const ensureParents = ( */ export function buildTermsTree( flatTerms: readonly ( Author | Category )[] ) { const flatTermsWithParentAndChildren: TermWithParentAndChildren[] = - flatTerms.map( ( term ) => { - return { - children: [], - parent: null, - ...term, - id: String( term.id ), - }; - } ); + flatTerms.map( ( term ) => ( { + children: [], + parent: null, + ...term, + id: String( term.id ), + } ) ); if ( ! ensureParents( flatTermsWithParentAndChildren ) ) { return flatTermsWithParentAndChildren; @@ -37,7 +35,7 @@ export function buildTermsTree( flatTerms: readonly ( Author | Category )[] ) { const termsByParent = flatTermsWithParentAndChildren.reduce( ( acc: TermsByParent, term ) => { - const parent = term.parent.toString(); + const { parent } = term; if ( ! acc[ parent ] ) { acc[ parent ] = []; }