Merge branch 'master' of ssh://numinibsd/git/base/enigma-bbs
This commit is contained in:
commit
886a6deceb
|
@ -25,13 +25,9 @@ const moment = require('moment');
|
||||||
MCI codes:
|
MCI codes:
|
||||||
|
|
||||||
VM1 : Message list
|
VM1 : Message list
|
||||||
TL2 : Message area description
|
TL2 : Message info 1: { msgNumSelected, msgNumTotal }
|
||||||
TL4 : Message selected #
|
|
||||||
TL5 : Total messages in area
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// :TODO: We need a way to update |initialFocusIndex| after next/prev in actual message viewing -- e.g. from child menu!!
|
|
||||||
|
|
||||||
exports.getModule = MessageListModule;
|
exports.getModule = MessageListModule;
|
||||||
|
|
||||||
exports.moduleInfo = {
|
exports.moduleInfo = {
|
||||||
|
@ -40,12 +36,9 @@ exports.moduleInfo = {
|
||||||
author : 'NuSkooler',
|
author : 'NuSkooler',
|
||||||
};
|
};
|
||||||
|
|
||||||
var MciCodesIds = {
|
const MCICodesIDs = {
|
||||||
MsgList : 1,
|
MsgList : 1, // VM1
|
||||||
MsgAreaDesc : 2,
|
MsgInfo1 : 2, // TL2
|
||||||
|
|
||||||
MsgSelNum : 4,
|
|
||||||
MsgTotal : 5,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function MessageListModule(options) {
|
function MessageListModule(options) {
|
||||||
|
@ -154,34 +147,34 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
|
||||||
MessageListModule.super_.prototype.mciReady.call(self, mciData, callback);
|
MessageListModule.super_.prototype.mciReady.call(self, mciData, callback);
|
||||||
},
|
},
|
||||||
function loadFromConfig(callback) {
|
function loadFromConfig(callback) {
|
||||||
var loadOpts = {
|
const loadOpts = {
|
||||||
callingMenu : self,
|
callingMenu : self,
|
||||||
mciMap : mciData.menu
|
mciMap : mciData.menu
|
||||||
};
|
};
|
||||||
|
|
||||||
vc.loadFromMenuConfig(loadOpts, callback);
|
return vc.loadFromMenuConfig(loadOpts, callback);
|
||||||
},
|
},
|
||||||
function fetchMessagesInArea(callback) {
|
function fetchMessagesInArea(callback) {
|
||||||
//
|
//
|
||||||
// Config can supply messages else we'll need to populate the list now
|
// Config can supply messages else we'll need to populate the list now
|
||||||
//
|
//
|
||||||
if(_.isArray(self.messageList)) {
|
if(_.isArray(self.messageList)) {
|
||||||
callback(0 === self.messageList.length ? new Error('No messages in area') : null);
|
return callback(0 === self.messageList.length ? new Error('No messages in area') : null);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
messageArea.getMessageListForArea( { client : self.client }, self.messageAreaTag, function msgs(err, msgList) {
|
messageArea.getMessageListForArea( { client : self.client }, self.messageAreaTag, function msgs(err, msgList) {
|
||||||
if(!msgList || 0 === msgList.length) {
|
if(!msgList || 0 === msgList.length) {
|
||||||
callback(new Error('No messages in area'));
|
return callback(new Error('No messages in area'));
|
||||||
} else {
|
}
|
||||||
|
|
||||||
self.messageList = msgList;
|
self.messageList = msgList;
|
||||||
callback(err);
|
return callback(err);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
function getLastReadMesageId(callback) {
|
function getLastReadMesageId(callback) {
|
||||||
messageArea.getMessageAreaLastReadId(self.client.user.userId, self.messageAreaTag, function lastRead(err, lastReadId) {
|
messageArea.getMessageAreaLastReadId(self.client.user.userId, self.messageAreaTag, function lastRead(err, lastReadId) {
|
||||||
self.lastReadId = lastReadId || 0;
|
self.lastReadId = lastReadId || 0;
|
||||||
callback(null); // ignore any errors, e.g. missing value
|
return callback(null); // ignore any errors, e.g. missing value
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function updateMessageListObjects(callback) {
|
function updateMessageListObjects(callback) {
|
||||||
|
@ -202,9 +195,10 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
|
||||||
return callback(null);
|
return callback(null);
|
||||||
},
|
},
|
||||||
function populateList(callback) {
|
function populateList(callback) {
|
||||||
const msgListView = vc.getView(MciCodesIds.MsgList);
|
const msgListView = vc.getView(MCICodesIDs.MsgList);
|
||||||
const listFormat = self.menuConfig.config.listFormat || '{msgNum} - {subject} - {toUserName}';
|
const listFormat = self.menuConfig.config.listFormat || '{msgNum} - {subject} - {toUserName}';
|
||||||
const focusListFormat = self.menuConfig.config.focusListFormat || listFormat; // :TODO: default change color here
|
const focusListFormat = self.menuConfig.config.focusListFormat || listFormat; // :TODO: default change color here
|
||||||
|
const messageInfo1Format = self.menuConfig.config.messageInfo1Format || '{msgNumSelected} / {msgNumTotal}';
|
||||||
|
|
||||||
// :TODO: This can take a very long time to load large lists. What we need is to implement the "owner draw" concept in
|
// :TODO: This can take a very long time to load large lists. What we need is to implement the "owner draw" concept in
|
||||||
// which items are requested (e.g. their format at least) *as-needed* vs trying to get the format for all of them at once
|
// which items are requested (e.g. their format at least) *as-needed* vs trying to get the format for all of them at once
|
||||||
|
@ -217,8 +211,10 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
|
||||||
return stringFormat(focusListFormat, listEntry);
|
return stringFormat(focusListFormat, listEntry);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
msgListView.on('index update', function indexUpdated(idx) {
|
msgListView.on('index update', idx => {
|
||||||
self.setViewText(MciCodesIds.MsgSelNum, (idx + 1).toString());
|
self.setViewText(
|
||||||
|
MCICodesIDs.MsgInfo1,
|
||||||
|
stringFormat(messageInfo1Format, { msgNumSelected : (idx + 1), msgNumTotal : self.messageList.length } ));
|
||||||
});
|
});
|
||||||
|
|
||||||
if(self.initialFocusIndex > 0) {
|
if(self.initialFocusIndex > 0) {
|
||||||
|
@ -228,21 +224,21 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
|
||||||
msgListView.redraw();
|
msgListView.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null);
|
return callback(null);
|
||||||
},
|
},
|
||||||
function populateOtherMciViews(callback) {
|
function drawOtherViews(callback) {
|
||||||
self.setViewText(MciCodesIds.MsgAreaDesc, messageArea.getMessageAreaByTag(self.messageAreaTag).name);
|
const messageInfo1Format = self.menuConfig.config.messageInfo1Format || '{msgNumSelected} / {msgNumTotal}';
|
||||||
self.setViewText(MciCodesIds.MsgSelNum, (vc.getView(MciCodesIds.MsgList).getData() + 1).toString());
|
self.setViewText(
|
||||||
self.setViewText(MciCodesIds.MsgTotal, self.messageList.length.toString());
|
MCICodesIDs.MsgInfo1,
|
||||||
|
stringFormat(messageInfo1Format, { msgNumSelected : self.initialFocusIndex + 1, msgNumTotal : self.messageList.length } ));
|
||||||
callback(null);
|
return callback(null);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
function complete(err) {
|
err => {
|
||||||
if(err) {
|
if(err) {
|
||||||
self.client.log.error( { error : err.message }, 'Error loading message list');
|
self.client.log.error( { error : err.message }, 'Error loading message list');
|
||||||
}
|
}
|
||||||
cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/NuSkooler/enigma-bbs.git"
|
"url": "https://github.com/NuSkooler/enigma-bbs.git"
|
||||||
},
|
},
|
||||||
|
"homepage": "https://github.com/NuSkooler/enigma-bbs",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/NuSkooler/enigma-bbs/issues"
|
||||||
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"bbs",
|
"bbs",
|
||||||
"telnet"
|
"telnet"
|
||||||
|
@ -25,7 +29,7 @@
|
||||||
"minimist": "1.2.x",
|
"minimist": "1.2.x",
|
||||||
"moment": "^2.11.0",
|
"moment": "^2.11.0",
|
||||||
"node-uuid": "^1.4.7",
|
"node-uuid": "^1.4.7",
|
||||||
"ptyw.js": "^0.3.7",
|
"ptyw.js": "NuSkooler/ptyw.js",
|
||||||
"sqlite3": "^3.1.1",
|
"sqlite3": "^3.1.1",
|
||||||
"ssh2": "^0.4.13",
|
"ssh2": "^0.4.13",
|
||||||
"temp": "^0.8.3",
|
"temp": "^0.8.3",
|
||||||
|
|
Loading…
Reference in New Issue