diff --git a/js/src/forum/components/SocialButtonsModal.js b/js/src/forum/components/SocialButtonsModal.js index 4ed74b1..3f5c0a5 100644 --- a/js/src/forum/components/SocialButtonsModal.js +++ b/js/src/forum/components/SocialButtonsModal.js @@ -12,7 +12,7 @@ export default class SocialButtonsModal extends Modal { if (buttons.length) { buttons.forEach((button, index) => { - if (button.title !== '') { + if (button && button.title) { this.createButtonObject(index, button); } }); @@ -77,16 +77,19 @@ export default class SocialButtonsModal extends Modal { data() { const buttons = []; - this.buttons.forEach((button, index) => { - if (button.title() !== '') { - buttons[index] = {}; - buttons[index].title = button.title(); - buttons[index].url = button.url(); - buttons[index].icon = button.icon(); - buttons[index].favicon = button.favicon(); + this.buttons.forEach((button) => { + if (button && button.title() && button.url()) { + buttons.push({ + title: button.title(), + url: button.url(), + icon: button.icon(), + favicon: button.favicon(), + }); } }); + console.log(JSON.stringify(buttons)); + return { socialButtons: JSON.stringify(buttons), }; diff --git a/js/src/forum/index.js b/js/src/forum/index.js index 8cf6656..07fcca6 100644 --- a/js/src/forum/index.js +++ b/js/src/forum/index.js @@ -28,7 +28,7 @@ app.initializers.add('fof/socialprofile', () => { if (this.buttons.length) { this.buttons.forEach((button, index) => { - if (button.title !== '' && button.icon !== '' && button.url !== '') { + if (button && button.title && button.icon && button.url) { let buttonStyle = ''; let buttonClassName = classList({ [`social-button ${button.icon}-${index} social-icon-${index}`]: true,