* Start some work on message list fetching

This commit is contained in:
Bryan Ashby 2015-08-26 23:25:49 -06:00
parent 3be271aab5
commit 140990811a
2 changed files with 48 additions and 15 deletions

View File

@ -34,22 +34,8 @@ function changeMessageArea(client, areaName, cb) {
async.waterfall( async.waterfall(
[ [
function getArea(callback) { function getArea(callback) {
/*
var availAreas = getAvailableMessageAreas();
areaName = areaName.toLowerCase(); // always lookup lowercase
var index = _.findIndex(availAreas, function pred(a) {
return a.name === areaName;
});
if(index > -1) {
callback(null, availAreas[index]);
} else {
callback(new Error('Invalid message area'));
}
*/
var area = getMessageAreaByName(areaName); var area = getMessageAreaByName(areaName);
if(area) { if(area) {
callback(null, area); callback(null, area);
} else { } else {
@ -77,3 +63,47 @@ function changeMessageArea(client, areaName, cb) {
} }
); );
} }
function getMessageListForArea(options, areaName, cb) {
//
// options.client (required)
//
assert(_.isObject(options.client));
/*
[
{
messageId, messageUuid, replyToId, toUserName, fromUserName, subject, modTimestamp,
status(new|old),
viewCount
}
]
*/
var msgList = [];
async.series(
[
function fetchMessages(callback) {
msgDb.each(
'SELECT message_id, message_uuid, reply_to_message_id, to_user_name, from_user_name, subject, modified_timestamp, view_count '
'FROM message '
'WHERE area_name=? '
'ORDER BY message_id;',
[ areaName.toLowerCase() ],
function msgRow(err, row) {
if(!err) {
msgList.push( {
id : row.message_id,
uuid : row.message_uuid,
replyToId : row.reply_to_message_id,
} );
}
},
callback
);
}
]
);
}

View File

@ -64,6 +64,9 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
}; };
vc.loadFromMenuConfig(loadOpts, callback); vc.loadFromMenuConfig(loadOpts, callback);
},
function fetchMessagesInArea(callback) {
} }
], ],
function complete(err) { function complete(err) {