From 1870db7d38aa1c5f9a16dc6391f26442474c204f Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Wed, 13 Jun 2018 20:59:43 -0600 Subject: [PATCH] Cleanup code for new getConditionalValue() support --- core/menu_stack.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/core/menu_stack.js b/core/menu_stack.js index 073dece5..360c2b38 100644 --- a/core/menu_stack.js +++ b/core/menu_stack.js @@ -52,18 +52,13 @@ module.exports = class MenuStack { const currentModuleInfo = this.top(); assert(currentModuleInfo, 'Empty menu stack!'); - const menuConfig = currentModuleInfo.instance.menuConfig; - let nextMenu; - - if(_.isArray(menuConfig.next)) { - nextMenu = this.client.acs.getConditionalValue(menuConfig.next, 'next'); - if(!nextMenu) { - return cb(Errors.MenuStack('No matching condition for "next"', 'NOCONDMATCH')); - } - } else if(_.isString(menuConfig.next)) { - nextMenu = menuConfig.next; - } else { - return cb(Errors.MenuStack('Invalid or missing "next" member in menu config', 'BADNEXT')); + const menuConfig = currentModuleInfo.instance.menuConfig; + const nextMenu = this.client.acs.getConditionalValue(menuConfig.next, 'next'); + if(!nextMenu) { + return cb(Array.isArray(menuConfig.next) ? + Errors.MenuStack('No matching condition for "next"', 'NOCONDMATCH') : + Errors.MenuStack('Invalid or missing "next" member in menu config', 'BADNEXT') + ); } if(nextMenu === currentModuleInfo.name) {