fix loading multiple blocks

This commit is contained in:
Daniel Waxweiler 2024-04-05 13:26:11 +02:00
parent 4f0752b0ac
commit d546157c93
2 changed files with 4 additions and 4 deletions

View File

@ -6,6 +6,7 @@
#### Deprecated
#### Removed
#### Fixed
- Not loading more than one block in Gutenberg editor
#### Security
### [0.11.5]

View File

@ -14,9 +14,8 @@ const { __ } = wp.i18n
const NAME = '<wordpress-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.')