1
0
mirror of https://github.com/dwaxweiler/connector-mobilizon synced 2025-06-05 21:59:25 +02:00

only reload current block's events

This commit is contained in:
Daniel Waxweiler
2022-06-06 12:16:12 +02:00
parent b3e9034ada
commit 456b4a9da1
5 changed files with 17 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/* eslint-disable @wordpress/i18n-ellipsis */
import { loadEventLists } from '../../events-loader.js'
import { loadEventList } from '../../events-loader.js'
const { InspectorControls } = wp.blockEditor
const { InspectorControls, useBlockProps } = wp.blockEditor
const { useEffect } = wp.element
const { PanelBody } = wp.components
const { __ } = wp.i18n
@ -9,11 +9,15 @@ const { __ } = wp.i18n
const NAME = '<wordpress-name>'
export default ({ attributes, setAttributes }) => {
const blockProps = useBlockProps()
useEffect(() => {
reloadEventLists()
}, [])
function reloadEventLists() {
loadEventLists()
const container = document.getElementById(blockProps.id)
if (container) {
loadEventList(container)
}
}
function updateEventsCount(event) {
let newValue = Number(event.target.value)
@ -60,6 +64,7 @@ export default ({ attributes, setAttributes }) => {
className={NAME + '_events-list'}
data-maximum={attributes.eventsCount}
data-group-name={attributes.groupName}
{...blockProps}
>
<div style={{ display: 'none' }}>
{__('The events could not be loaded!', '<wordpress-name>')}