Hiding badge when remaining tasks is now zero

This commit is contained in:
Joel T 2022-04-27 13:39:01 -07:00
parent 29e521dca0
commit 27cecd9b83
3 changed files with 8 additions and 2 deletions

View File

@ -35,6 +35,11 @@ export const Task: React.FC< TaskProps > = ( { query, task } ) => {
}
const currentBadgeCount = Number( badgeElement.innerText );
if ( currentBadgeCount === 1 ) {
badgeElement.remove();
}
badgeElement.innerHTML = String( currentBadgeCount - 1 );
}, [] );

View File

@ -190,6 +190,7 @@ class CoreMenu {
}
$home_item = array();
$setup_tasks_remaining = TaskLists::setup_tasks_remaining();
if ( defined( '\Automattic\WooCommerce\Internal\Admin\Homescreen::MENU_SLUG' ) ) {
$home_item = array(
'id' => 'woocommerce-home',
@ -197,7 +198,7 @@ class CoreMenu {
'url' => \Automattic\WooCommerce\Internal\Admin\Homescreen::MENU_SLUG,
'order' => 0,
'matchExpression' => 'page=wc-admin((?!path=).)*$',
'badge' => TaskLists::setup_tasks_remaining(),
'badge' => $setup_tasks_remaining ? $setup_tasks_remaining : null,
);
}

View File

@ -497,7 +497,7 @@ class TaskLists {
$tasks_count = self::setup_tasks_remaining();
if( !$tasks_count ) {
if( ! $tasks_count ) {
return;
}