This commit is contained in:
John McLear 2020-03-12 16:51:35 +00:00 committed by muxator
parent bb868beb9c
commit 467fc11b72

View file

@ -68,7 +68,7 @@ ButtonsGroup.prototype.addButton = function (button) {
}; };
ButtonsGroup.prototype.render = function () { ButtonsGroup.prototype.render = function () {
if (this.buttons.length == 1) { if (this.buttons && this.buttons.length == 1) {
this.buttons[0].grouping = ""; this.buttons[0].grouping = "";
} }
else { else {
@ -80,7 +80,7 @@ ButtonsGroup.prototype.render = function () {
} }
return _.map(this.buttons, function (btn) { return _.map(this.buttons, function (btn) {
return btn.render(); if(btn) return btn.render();
}).join("\n"); }).join("\n");
}; };
@ -90,12 +90,17 @@ Button = function (attributes) {
Button.load = function (btnName) { Button.load = function (btnName) {
var button = module.exports.availableButtons[btnName]; var button = module.exports.availableButtons[btnName];
try{
if (button.constructor === Button || button.constructor === SelectButton) { if (button.constructor === Button || button.constructor === SelectButton) {
return button; return button;
} }
else { else {
return new Button(button); return new Button(button);
} }
}catch(e){
console.warn("Error loading button", btnName);
return false;
}
}; };
_.extend(Button.prototype, { _.extend(Button.prototype, {