Rely on pty.js, minor updates to area changing logic

This commit is contained in:
Bryan Ashby 2015-08-18 23:11:13 -06:00
parent c9a24b7ec8
commit d3f82e38da
5 changed files with 25 additions and 16 deletions

View File

@ -5,7 +5,7 @@ var spawn = require('child_process').spawn;
var events = require('events'); var events = require('events');
var _ = require('lodash'); var _ = require('lodash');
var pty = require('pty'); var pty = require('pty.js');
exports.Door = Door; exports.Door = Door;

View File

@ -75,6 +75,12 @@ function changeCurrentArea(client, areaId, cb) {
} }
], ],
function complete(err) { function complete(err) {
if(!err) {
client.log.info( { areaId : areaId }, 'Current message area changed');
} else {
client.log.warn( { areaId : areaId, error : err.message }, 'Could not change message area');
}
cb(err); cb(err);
} }
); );

View File

@ -301,7 +301,13 @@
"action" : "@method:changeArea" "action" : "@method:changeArea"
} }
] ]
},
"actionKeys" : [ // :TODO: Need better name
{
"keys" : [ "escape" ],
"action" : "@menu:messageArea"
} }
]
} }
} }
} }

View File

@ -37,7 +37,15 @@ function MessageAreaListModule(options) {
if(1 === formData.submitId) { if(1 === formData.submitId) {
var areaId = self.messageAreas[formData.value.area].areaId; var areaId = self.messageAreas[formData.value.area].areaId;
messageArea.changeCurrentArea(self.client, areaId, function areaChanged(err) { messageArea.changeCurrentArea(self.client, areaId, function areaChanged(err) {
if(err) {
self.client.term.write('\nCannot change area: ' + err.message + '\n');
setTimeout(function timeout() {
self.client.gotoMenuModule( { name : self.menuConfig.fallback } ); self.client.gotoMenuModule( { name : self.menuConfig.fallback } );
}, 1000);
} else {
self.client.gotoMenuModule( { name : self.menuConfig.fallback } );
}
}); });
} }
} }
@ -61,8 +69,6 @@ MessageAreaListModule.prototype.mciReady = function(mciData, cb) {
var self = this; var self = this;
var vc = self.viewControllers.areaList = new ViewController( { client : self.client } ); var vc = self.viewControllers.areaList = new ViewController( { client : self.client } );
//var messageAreas = [];
async.series( async.series(
[ [
function callParentMciReady(callback) { function callParentMciReady(callback) {
@ -81,14 +87,6 @@ MessageAreaListModule.prototype.mciReady = function(mciData, cb) {
callback(err); callback(err);
}); });
}, },
/*
function fetchAreaData(callback) {
messageArea.getAvailableMessageAreas(function fetched(err, areas) {
messageAreas = areas;
callback(err);
});
},
*/
function populateAreaListView(callback) { function populateAreaListView(callback) {
var areaListView = vc.getView(1); var areaListView = vc.getView(1);
@ -99,8 +97,6 @@ MessageAreaListModule.prototype.mciReady = function(mciData, cb) {
areaList.push(strUtil.format(self.entryFormat, msgArea)); areaList.push(strUtil.format(self.entryFormat, msgArea));
}); });
console.log(areaList)
areaListView.setItems(areaList); areaListView.setItems(areaList);
areaListView.redraw(); areaListView.redraw();
} }

View File

@ -17,7 +17,8 @@
"node-uuid" : "1.4.x", "node-uuid" : "1.4.x",
"moment" : "2.10.x", "moment" : "2.10.x",
"gaze" : "0.5.x", "gaze" : "0.5.x",
"mkdirp" : "0.5.x" "mkdirp" : "0.5.x",
"pty.js" : "0.2.x"
}, },
"engine" : "node >= 0.12.2" "engine" : "node >= 0.12.2"
} }