Skip to content

Commit

Permalink
Fix issue with empty button objects & fields crashing profiles
Browse files Browse the repository at this point in the history
Closes #26
  • Loading branch information
dsevillamartin committed Dec 8, 2021
1 parent bdd79a7 commit 865ecc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions js/src/forum/components/SocialButtonsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down Expand Up @@ -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),
};
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 865ecc8

Please sign in to comment.