* Fix 'noHistory' flag and it's usage to be more natural

* Add 'popParent' menu flag (works like 'noHistory' used to)
This commit is contained in:
Bryan Ashby 2017-12-02 19:06:07 -07:00
parent 1849d275f5
commit 7f80f4a7af
4 changed files with 14 additions and 13 deletions

View file

@ -129,15 +129,19 @@ module.exports = class MenuStack {
} else {
self.client.log.debug( { menuName : name }, 'Goto menu module');
const menuFlags = (options && Array.isArray(options.menuFlags)) ? options.menuFlags : modInst.menuConfig.options.menuFlags;
if(currentModuleInfo) {
// save stack state
currentModuleInfo.savedState = currentModuleInfo.instance.getSaveState();
currentModuleInfo.instance.leave();
const menuFlags = (options && Array.isArray(options.menuFlags)) ? options.menuFlags : modInst.menuConfig.options.menuFlags;
if(currentModuleInfo.menuFlags.includes('noHistory')) {
this.pop();
}
if(menuFlags.includes('noHistory')) {
if(menuFlags.includes('popParent')) {
this.pop().instance.leave(); // leave & remove current
}
}
@ -146,6 +150,7 @@ module.exports = class MenuStack {
name : name,
instance : modInst,
extraArgs : loadOpts.extraArgs,
menuFlags : menuFlags,
});
// restore previous state if requested