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,14 +1,15 @@
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) {
(Object.values(tainacan_plugin.tainacan_media_components) || []).forEach((component) => {
new tainacan_plugin.classes.TainacanMediaGallery(
component.has_media_thumbs ? '#' + component.media_thumbs_id : null,
component.has_media_main ? '#' + component.media_main_id : null,
component
);
});
}
document.dispatchEvent(new Event('TainacanReloadItemsListComponent'));
});
/* Handles updating Media Items component when reloading page from customizer */
if (window.ctEvents && window.ctEvents.default) {
window.ctEvents.default.on('blocksy:frontend:init', () => {
if (tainacan_plugin?.classes?.TainacanMediaGallery && tainacan_plugin?.tainacan_media_components) {
(Object.values(tainacan_plugin.tainacan_media_components) || []).forEach((component) => {
new tainacan_plugin.classes.TainacanMediaGallery(
component.has_media_thumbs ? '#' + component.media_thumbs_id : null,
component.has_media_main ? '#' + component.media_main_id : null,
component
);
});
}
document.dispatchEvent(new Event('TainacanReloadItemsListComponent'));
});
}