From d546157c93ba125294d8145af1b0a57f4772e50b Mon Sep 17 00:00:00 2001 From: Daniel Waxweiler Date: Fri, 5 Apr 2024 13:26:11 +0200 Subject: [PATCH] fix loading multiple blocks --- source/changelog.txt | 1 + source/front/blocks/events-list/edit.js | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/changelog.txt b/source/changelog.txt index 5d50817..1d1862c 100644 --- a/source/changelog.txt +++ b/source/changelog.txt @@ -6,6 +6,7 @@ #### Deprecated #### Removed #### Fixed +- Not loading more than one block in Gutenberg editor #### Security ### [0.11.5] diff --git a/source/front/blocks/events-list/edit.js b/source/front/blocks/events-list/edit.js index d758a71..0294cd2 100644 --- a/source/front/blocks/events-list/edit.js +++ b/source/front/blocks/events-list/edit.js @@ -14,9 +14,8 @@ const { __ } = wp.i18n const NAME = '' -let timer - export default ({ attributes, setAttributes }) => { + let timer const { eventsCount, groupName } = attributes const blockProps = useBlockProps({ className: NAME + '_events-list', @@ -25,7 +24,7 @@ export default ({ attributes, setAttributes }) => { if (timer) { clearTimeout(timer) } - timer = setTimeout(() => { + timer = setTimeout(async () => { const container = document.getElementById(blockProps.id) if (container) { hideErrorMessages(container) @@ -35,7 +34,7 @@ export default ({ attributes, setAttributes }) => { if (groupName) { url += `&groupName=${groupName}` } - fetch(url) + await fetch(url) .then((response) => { if (!response.ok) { return Promise.reject('Network response was not OK.')