Reintroduce the client-side filtering of email templates

We still need to filter the templates because, in some cases, the API also returns custom templates
ignoring the post_type filter in the query
[MAILPOET-6279]
This commit is contained in:
Rostislav Wolny
2024-10-16 16:14:05 +02:00
committed by Jan Lysý
parent 1626ded39a
commit c015092133

View File

@ -196,10 +196,18 @@ export const getCurrentTemplate = createRegistrySelector((select) => () => {
*/ */
export const getEmailTemplates = createRegistrySelector( export const getEmailTemplates = createRegistrySelector(
(select) => () => (select) => () =>
select(coreDataStore).getEntityRecords('postType', 'wp_template', { select(coreDataStore)
per_page: -1, .getEntityRecords('postType', 'wp_template', {
post_type: 'mailpoet_email', per_page: -1,
}), post_type: 'mailpoet_email',
})
// We still need to filter the templates because, in some cases, the API also returns custom templates
// ignoring the post_type filter in the query
?.filter(
(template) =>
// @ts-expect-error Missing property in type
template.theme === 'mailpoet/mailpoet',
),
); );
export function getEmailPostId(state: State): number { export function getEmailPostId(state: State): number {