diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js index 02a86c11942..af825aaf737 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js @@ -90,7 +90,11 @@ class InboxPanel extends Component { title={ note.title } date={ note.date_created_gmt } icon={ } - unread={ ! lastRead || new Date( note.date_created_gmt ).getTime() > lastRead } + unread={ + ! lastRead || + ! note.date_created_gmt || + new Date( note.date_created_gmt + 'Z' ).getTime() > lastRead + } actions={ getButtonsFromActions( note.actions ) } > diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js index 74235793e85..20666793266 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js @@ -151,7 +151,7 @@ function OrdersPanel( { orders, isRequesting, isError, orderStatuses } ) { key={ order.order_id } className="woocommerce-order-activity-card" title={ orderCardTitle( order ) } - date={ order.date_created } + date={ order.date_created_gmt } subtitle={
diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/reviews.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/reviews.js index 7d178680df4..17e4af88002 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/reviews.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/reviews.js @@ -8,7 +8,6 @@ import { Component, Fragment } from '@wordpress/element'; import { compose } from '@wordpress/compose'; import Gridicon from 'gridicons'; import interpolateComponents from 'interpolate-components'; -import moment from 'moment'; import { get, noop, isNull } from 'lodash'; import PropTypes from 'prop-types'; import { withDispatch } from '@wordpress/data'; @@ -135,11 +134,7 @@ class ReviewsPanel extends Component { key={ review.id } title={ title } subtitle={ subtitle } - date={ - review.date_created_gmt - ? moment( review.date_created_gmt + 'Z' ).format( 'YYYY-MM-DDTH:mm:ss' ) - : null - } + date={ review.date_created_gmt } icon={ icon } actions={ cardActions() } unread={ diff --git a/plugins/woocommerce-admin/client/header/activity-panel/unread-indicators.js b/plugins/woocommerce-admin/client/header/activity-panel/unread-indicators.js index 04a48101034..f6c8352299b 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/unread-indicators.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/unread-indicators.js @@ -17,11 +17,17 @@ export function getUnreadNotes( select ) { }; const latestNote = getNotes( notesQuery ); + const isError = Boolean( getNotesError( notesQuery ) ); + const isRequesting = isGetNotesRequesting( notesQuery ); + + if ( isError || isRequesting ) { + return null; + } + return ( - ! Boolean( getNotesError( notesQuery ) ) && - ! isGetNotesRequesting( notesQuery ) && latestNote[ 0 ] && - new Date( latestNote[ 0 ].date_created_gmt ).getTime() > userData.activity_panel_inbox_last_read + new Date( latestNote[ 0 ].date_created_gmt + 'Z' ).getTime() > + userData.activity_panel_inbox_last_read ); } @@ -44,13 +50,11 @@ export function getUnreadOrders( select ) { const isError = Boolean( getReportItemsError( 'orders', ordersQuery ) ); const isRequesting = isReportItemsRequesting( 'orders', ordersQuery ); - if ( ! isError && ! isRequesting ) { - if ( totalOrders > 0 ) { - return true; - } - return false; + if ( isError || isRequesting ) { + return null; } - return null; + + return totalOrders > 0; } export function getUnreadReviews( select ) { @@ -119,9 +123,12 @@ export function getUnreadStock( select ) { }; getItems( 'products', productsQuery ); const lowInStockCount = getItemsTotalCount( 'products', productsQuery ); + const isError = Boolean( getItemsError( 'products', productsQuery ) ); + const isRequesting = isGetItemsRequesting( 'products', productsQuery ); - return ! getItemsError( 'products', productsQuery ) && - ! isGetItemsRequesting( 'products', productsQuery ) - ? lowInStockCount > 0 - : false; + if ( isError || isRequesting ) { + return null; + } + + return lowInStockCount > 0; }