Skip to content

Commit 84d7336

Browse files
committed
Forms: Optimize inbox data loading with _fields parameter
Reduces payload size by explicitly requesting only required fields. Related: #45339
1 parent 845fb3a commit 84d7336

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: changed
3+
4+
Forms: optimize inbox data loading with _fields parameter to reduce payload size.

projects/packages/forms/src/dashboard/hooks/use-inbox-data.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ interface UseInboxDataReturn {
4747
filterOptions: Record< string, unknown >;
4848
}
4949

50+
const RESPONSE_FIELDS = [
51+
'id',
52+
'status',
53+
'date',
54+
'date_gmt',
55+
'author_name',
56+
'author_email',
57+
'author_url',
58+
'author_avatar',
59+
'ip',
60+
'entry_title',
61+
'entry_permalink',
62+
'has_file',
63+
'fields',
64+
].join( ',' );
65+
5066
/**
5167
* Hook to get all inbox related data.
5268
*
@@ -73,7 +89,10 @@ export default function useInboxData(): UseInboxDataReturn {
7389
isResolving: isLoadingRecordsData,
7490
totalItems,
7591
totalPages,
76-
} = useEntityRecords( 'postType', 'feedback', currentQuery );
92+
} = useEntityRecords( 'postType', 'feedback', {
93+
...currentQuery,
94+
_fields: RESPONSE_FIELDS,
95+
} );
7796

7897
const records = ( rawRecords || [] ) as FormResponse[];
7998

0 commit comments

Comments
 (0)