Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/packages/forms/changelog/optimize-inbox-fields
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Forms: optimize inbox data loading with _fields parameter to reduce payload size.
21 changes: 20 additions & 1 deletion projects/packages/forms/src/dashboard/hooks/use-inbox-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ interface UseInboxDataReturn {
filterOptions: Record< string, unknown >;
}

const RESPONSE_FIELDS = [
'id',
'status',
'date',
'date_gmt',
'author_name',
'author_email',
'author_url',
'author_avatar',
'ip',
'entry_title',
'entry_permalink',
'has_file',
'fields',
].join( ',' );

/**
* Hook to get all inbox related data.
*
Expand All @@ -73,7 +89,10 @@ export default function useInboxData(): UseInboxDataReturn {
isResolving: isLoadingRecordsData,
totalItems,
totalPages,
} = useEntityRecords( 'postType', 'feedback', currentQuery );
} = useEntityRecords( 'postType', 'feedback', {
...currentQuery,
_fields: RESPONSE_FIELDS,
} );

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

Expand Down
Loading