Update timing of InboxPanel state changes for the unread indicator (https://github.com/woocommerce/woocommerce-admin/pull/6246)
This commit is contained in:
parent
82d0f04451
commit
2ae0168705
|
@ -2,7 +2,7 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useEffect } from '@wordpress/element';
|
||||
import { useEffect, useState } from '@wordpress/element';
|
||||
import { compose } from '@wordpress/compose';
|
||||
import { EmptyContent, Section } from '@woocommerce/components';
|
||||
import {
|
||||
|
@ -74,17 +74,15 @@ const renderNotes = ( { hasNotes, isBatchUpdating, lastRead, notes } ) => {
|
|||
const InboxPanel = ( props ) => {
|
||||
const { isError, isResolving, isBatchUpdating, notes } = props;
|
||||
const { updateUserPreferences, ...userPrefs } = useUserPreferences();
|
||||
const lastRead = userPrefs.activity_panel_inbox_last_read;
|
||||
const [ lastRead ] = useState( userPrefs.activity_panel_inbox_last_read );
|
||||
|
||||
useEffect( () => {
|
||||
const mountTime = Date.now();
|
||||
|
||||
return () => {
|
||||
const userDataFields = {
|
||||
activity_panel_inbox_last_read: mountTime,
|
||||
};
|
||||
updateUserPreferences( userDataFields );
|
||||
};
|
||||
}, [] );
|
||||
|
||||
if ( isError ) {
|
||||
|
|
Loading…
Reference in New Issue