WIP on real-time interruptions (ie: incoming message)

Still need work on *when* they are allowed with good defaults, etc.
This commit is contained in:
Bryan Ashby 2018-11-14 22:47:20 -07:00
parent 4025c3c643
commit 080d1727c2
2 changed files with 35 additions and 17 deletions

View file

@ -35,8 +35,17 @@ module.exports = class UserInterruptQueue
if(!_.isString(interruptItem.contents) && !_.isString(interruptItem.text)) {
return;
}
// pause defaulted on
interruptItem.pause = _.get(interruptItem, 'pause', true);
this.queue.push(interruptItem);
this.client.currentMenuModule.attemptInterruptNow(interruptItem, (err, ateIt) => {
if(err) {
// :TODO: Log me
} else if(true !== ateIt) {
this.queue.push(interruptItem);
}
});
}
hasItems() {
@ -61,8 +70,13 @@ module.exports = class UserInterruptQueue
if(interruptItem.contents) {
Art.display(this.client, interruptItem.contents, err => {
this.client.term.rawWrite('\r\n\r\n');
return cb(err, interruptItem);
if(err) {
return cb(err);
}
//this.client.term.rawWrite('\r\n\r\n'); // :TODO: Prob optional based on contents vs text
this.client.currentMenuModule.pausePrompt( () => {
return cb(null);
});
});
} else {
return this.client.term.write(pipeToAnsi(`${interruptItem.text}\r\n\r\n`, this.client), cb);