Update timing of InboxPanel state changes for the unread indicator (https://github.com/woocommerce/woocommerce-admin/pull/6246)

This commit is contained in:
Hsing-Yu Flowers 2021-02-17 22:45:43 -05:00 committed by GitHub
parent 82d0f04451
commit 2ae0168705
1 changed files with 5 additions and 7 deletions

View File

@ -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 ) {