Removes console log and checks if ctEvents are available before using it.

This commit is contained in:
mateuswetah 2021-04-27 14:43:03 -03:00
parent 9d7d97ebfa
commit 8c315eb10d
1 changed files with 15 additions and 14 deletions

View File

@ -1,5 +1,6 @@
/* Handles updating Media Items component when reloading page from customizer */
if (window.ctEvents && window.ctEvents.default) {
window.ctEvents.default.on('blocksy:frontend:init', () => { window.ctEvents.default.on('blocksy:frontend:init', () => {
console.log("Resetar mais coisas aqui...", tainacan_plugin);
if (tainacan_plugin?.classes?.TainacanMediaGallery && tainacan_plugin?.tainacan_media_components) { if (tainacan_plugin?.classes?.TainacanMediaGallery && tainacan_plugin?.tainacan_media_components) {
(Object.values(tainacan_plugin.tainacan_media_components) || []).forEach((component) => { (Object.values(tainacan_plugin.tainacan_media_components) || []).forEach((component) => {
new tainacan_plugin.classes.TainacanMediaGallery( new tainacan_plugin.classes.TainacanMediaGallery(
@ -9,6 +10,6 @@ window.ctEvents.default.on('blocksy:frontend:init', () => {
); );
}); });
} }
document.dispatchEvent(new Event('TainacanReloadItemsListComponent')); document.dispatchEvent(new Event('TainacanReloadItemsListComponent'));
}); });
}