mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-28 13:36:16 +02:00
Add 'write' access for post FSE
+ hasMessageConfAndAreaWrite() + MenuModule helpers: gotoMenuOrPrev(), gotoMenuOrShowMessage(). These will likely replace many other pieces of code soon.
This commit is contained in:
parent
7783262af6
commit
1fdaaf5633
3 changed files with 68 additions and 5 deletions
|
@ -259,6 +259,44 @@ exports.MenuModule = class MenuModule extends PluginModule {
|
|||
return this.client.menuStack.goto(name, options, cb);
|
||||
}
|
||||
|
||||
gotoMenuOrPrev(name, options, cb) {
|
||||
this.client.menuStack.goto(name, options, err => {
|
||||
if(!err) {
|
||||
if(cb) {
|
||||
return cb(null);
|
||||
}
|
||||
}
|
||||
|
||||
return this.prevMenu(cb);
|
||||
});
|
||||
}
|
||||
|
||||
gotoMenuOrShowMessage(name, message, options, cb) {
|
||||
if(!cb && _.isFunction(options)) {
|
||||
cb = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
options = options || { clearScreen: true };
|
||||
|
||||
this.gotoMenu(name, options, err => {
|
||||
if(err) {
|
||||
if(options.clearScreen) {
|
||||
this.client.term.rawWrite(ansi.resetScreen());
|
||||
}
|
||||
|
||||
this.client.term.write(`${message}\n`);
|
||||
return this.pausePrompt( () => {
|
||||
return this.prevMenu(cb);
|
||||
});
|
||||
}
|
||||
|
||||
if(cb) {
|
||||
return cb(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
reload(cb) {
|
||||
const prevMenu = this.client.menuStack.pop();
|
||||
prevMenu.instance.leave();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue