use different global object name

This commit is contained in:
Daniel Waxweiler 2022-06-06 12:51:14 +02:00
parent c4c3b11baf
commit 68bb45b9a4
5 changed files with 7 additions and 7 deletions

View File

@ -4,7 +4,7 @@
"es2020": true
},
"globals": {
"SETTINGS": "readonly"
"MOBILIZON_CONNECTOR": "readonly"
},
"parser": "@babel/eslint-parser",
"extends": [

View File

@ -51,7 +51,7 @@ final class Mobilizon_Connector {
'timeZone' => wp_timezone_string(),
'url' => MobilizonConnector\Settings::getUrl()
);
wp_add_inline_script($scriptName, 'const SETTINGS = ' . json_encode($settings), 'before'); // TODO use different name
wp_add_inline_script($scriptName, 'const MOBILIZON_CONNECTOR = ' . json_encode($settings), 'before');
}
public function register_blocks() {

View File

@ -8,7 +8,7 @@ let document
test.before(() => {
const window = new JSDOM().window
document = window.document
window.SETTINGS = {
window.MOBILIZON_CONNECTOR = {
locale: 'en-GB',
timeZone: 'utc',
}

View File

@ -9,10 +9,10 @@ export function clearEventsList(container) {
export function displayEvents({ data, document, container }) {
hideLoadingIndicator(container)
const isShortOffsetNameShown = SETTINGS.isShortOffsetNameShown
const locale = SETTINGS.locale
const isShortOffsetNameShown = MOBILIZON_CONNECTOR.isShortOffsetNameShown
const locale = MOBILIZON_CONNECTOR.locale
const maxEventsCount = container.getAttribute('data-maximum')
const timeZone = SETTINGS.timeZone
const timeZone = MOBILIZON_CONNECTOR.timeZone
const events = data.events
? data.events.elements

View File

@ -19,7 +19,7 @@ function loadEventLists() {
}
export function loadEventList(container) {
const url = SETTINGS.url + URL_SUFFIX
const url = MOBILIZON_CONNECTOR.url + URL_SUFFIX
const limit = parseInt(container.getAttribute('data-maximum'))
const groupName = container.getAttribute('data-group-name')
clearEventsList(container)