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
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { useEffect } from '@wordpress/element';
|
import { useEffect, useState } from '@wordpress/element';
|
||||||
import { compose } from '@wordpress/compose';
|
import { compose } from '@wordpress/compose';
|
||||||
import { EmptyContent, Section } from '@woocommerce/components';
|
import { EmptyContent, Section } from '@woocommerce/components';
|
||||||
import {
|
import {
|
||||||
|
@ -74,17 +74,15 @@ const renderNotes = ( { hasNotes, isBatchUpdating, lastRead, notes } ) => {
|
||||||
const InboxPanel = ( props ) => {
|
const InboxPanel = ( props ) => {
|
||||||
const { isError, isResolving, isBatchUpdating, notes } = props;
|
const { isError, isResolving, isBatchUpdating, notes } = props;
|
||||||
const { updateUserPreferences, ...userPrefs } = useUserPreferences();
|
const { updateUserPreferences, ...userPrefs } = useUserPreferences();
|
||||||
const lastRead = userPrefs.activity_panel_inbox_last_read;
|
const [ lastRead ] = useState( userPrefs.activity_panel_inbox_last_read );
|
||||||
|
|
||||||
useEffect( () => {
|
useEffect( () => {
|
||||||
const mountTime = Date.now();
|
const mountTime = Date.now();
|
||||||
|
|
||||||
return () => {
|
|
||||||
const userDataFields = {
|
const userDataFields = {
|
||||||
activity_panel_inbox_last_read: mountTime,
|
activity_panel_inbox_last_read: mountTime,
|
||||||
};
|
};
|
||||||
updateUserPreferences( userDataFields );
|
updateUserPreferences( userDataFields );
|
||||||
};
|
|
||||||
}, [] );
|
}, [] );
|
||||||
|
|
||||||
if ( isError ) {
|
if ( isError ) {
|
||||||
|
|
Loading…
Reference in New Issue