Skip to content

Commit ae6d71e

Browse files
committed
Mark note as read after 3s delay
1 parent 43171ec commit ae6d71e

File tree

1 file changed

+8
-5
lines changed
  • plugins/woocommerce-admin/client/inbox-panel

1 file changed

+8
-5
lines changed

plugins/woocommerce-admin/client/inbox-panel/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ const InboxPanel = ( { showHeader = true } ) => {
207207
);
208208
const [ allNotesFetched, setAllNotesFetched ] = useState( false );
209209
const [ allNotes, setAllNotes ] = useState( [] );
210+
const [ viewedNotes, setViewedNotes ] = useState( {} );
210211
const { createNotice } = useDispatch( 'core/notices' );
211212
const {
212213
removeNote,
@@ -241,7 +242,6 @@ const InboxPanel = ( { showHeader = true } ) => {
241242
notes: getNotes( inboxQuery ),
242243
unreadNotesCount: getNotes( {
243244
...DEFAULT_INBOX_QUERY,
244-
_fields: [ 'id' ],
245245
is_read: false,
246246
per_page: -1,
247247
} ).length,
@@ -287,10 +287,13 @@ const InboxPanel = ( { showHeader = true } ) => {
287287
const [ showDismissAllModal, setShowDismissAllModal ] = useState( false );
288288

289289
const onNoteVisible = ( note ) => {
290-
if ( ! note.is_read ) {
291-
updateNote( note.id, {
292-
is_read: true,
293-
} );
290+
if ( ! viewedNotes[ note.id ] && ! note.is_read ) {
291+
setViewedNotes( { ...viewedNotes, [ note.id ]: true } );
292+
setTimeout( () => {
293+
updateNote( note.id, {
294+
is_read: true,
295+
} );
296+
}, 3000 );
294297
}
295298
recordEvent( 'inbox_note_view', {
296299
note_content: note.content,

0 commit comments

Comments
 (0)