File tree Expand file tree Collapse file tree 3 files changed +24
-11
lines changed
projects/packages/forms/src/dashboard Expand file tree Collapse file tree 3 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,7 @@ const ResponseViewBody = ( {
211211 const [ isImageLoading , setIsImageLoading ] = useState ( true ) ;
212212 const [ hasMarkedSelfAsRead , setHasMarkedSelfAsRead ] = useState ( 0 ) ;
213213
214- const { editEntityRecord } = useDispatch ( 'core' ) ;
214+ const { editEntityRecord, saveEditedEntityRecord } = useDispatch ( 'core' ) ;
215215
216216 const emptyTrashDays = useConfigValue ( 'emptyTrashDays' ) ?? 0 ;
217217
@@ -376,10 +376,13 @@ const ResponseViewBody = ( {
376376 }
377377
378378 // Then update on server
379- apiFetch ( {
380- path : `/wp/v2/feedback/${ response . id } /read` ,
381- method : 'POST' ,
382- data : { is_unread : false } ,
379+ saveEditedEntityRecord ( 'postType' , 'feedback' , response . id , {
380+ __unstableFetch : ( ) =>
381+ apiFetch ( {
382+ path : `/wp/v2/feedback/${ response . id } /read` ,
383+ method : 'POST' ,
384+ data : { is_unread : false } ,
385+ } ) ,
383386 } )
384387 . then ( ( { count } : { count : number } ) => {
385388 // Update menu counter with accurate count from server
@@ -407,6 +410,7 @@ const ResponseViewBody = ( {
407410 invalidateCounts ,
408411 markRecordsAsInvalid ,
409412 currentQuery ,
413+ saveEditedEntityRecord ,
410414 ] ) ;
411415
412416 const handelImageLoaded = useCallback ( ( ) => {
Original file line number Diff line number Diff line change @@ -569,7 +569,7 @@ export const markAsReadAction: Action = {
569569 multiple : items . length > 1 ,
570570 } ) ;
571571
572- const { editEntityRecord } = registry . dispatch ( coreStore ) ;
572+ const { editEntityRecord, saveEditedEntityRecord } = registry . dispatch ( coreStore ) ;
573573 const { getEntityRecord } = registry . select ( coreStore ) ;
574574 const { createSuccessNotice, createErrorNotice } = registry . dispatch ( noticesStore ) ;
575575 const { invalidateCounts, markRecordsAsInvalid } = registry . dispatch ( dashboardStore ) ;
@@ -592,12 +592,15 @@ export const markAsReadAction: Action = {
592592 }
593593
594594 // Update on server
595- return apiFetch ( {
596- path : `/wp/v2/feedback/${ id } /read` ,
597- method : 'POST' ,
598- data : { is_unread : false } ,
595+ return saveEditedEntityRecord ( 'postType' , 'feedback' , id , {
596+ __unstableFetch : ( ) =>
597+ apiFetch ( {
598+ path : `/wp/v2/feedback/${ id } /read` ,
599+ method : 'POST' ,
600+ data : { is_unread : false } ,
601+ } ) ,
599602 } )
600- . then ( ( { count } ) => {
603+ . then ( ( { count } : { count : number } ) => {
601604 // Update menu counter with accurate count from server.
602605 updateMenuCounter ( count ) ;
603606 } )
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ export type Registry = {
3535 name : string ,
3636 record : Record < string , unknown >
3737 ) => Promise < void > ;
38+ saveEditedEntityRecord : (
39+ kind : string ,
40+ name : string ,
41+ recordId : number ,
42+ options ?: { __unstableFetch ?: ( ) => Promise < void > }
43+ ) => Promise < { id : string ; count : number } > ;
3844 deleteEntityRecord : (
3945 kind : string ,
4046 name : string ,
You can’t perform that action at this time.
0 commit comments