* Some progress on message list fetching / display... WIP!

This commit is contained in:
Bryan Ashby 2015-08-27 22:20:24 -06:00
parent ede00f8937
commit 8dc06cb49d
5 changed files with 56 additions and 8 deletions

View File

@ -136,6 +136,16 @@ function createMessageBaseTables() {
' message_id INTEGER NOT NULL' +
');'
);
dbs.message.run(
'CREATE TABLE IF NOT EXISTS user_message_status (' +
' user_id INTEGER NOT NULL,' +
' message_id INTEGER NOT NULL,' +
' status INTEGER NOT NULL,' +
' UNIQUE(user_id, message_id, status),' +
' FOREIGN KEY(user_id) REFERENCES user(id)' +
');'
);
}
function createInitialMessageValues() {

View File

@ -78,6 +78,11 @@ Message.WellKnownAreaNames = {
Private : 'private_mail'
};
Message.Status = {
New : 0,
Read : 1,
};
Message.MetaCategories = {
System : 1, // ENiGMA1/2 stuff
FtnProperty : 2, // Various FTN network properties, ftn_cost, ftn_origin, ...

View File

@ -11,6 +11,7 @@ var assert = require('assert');
exports.getAvailableMessageAreas = getAvailableMessageAreas;
exports.getMessageAreaByName = getMessageAreaByName;
exports.changeMessageArea = changeMessageArea;
exports.getMessageListForArea = getMessageListForArea;
function getAvailableMessageAreas() {
return Config.messages.areas;
@ -95,15 +96,26 @@ function getMessageListForArea(options, areaName, cb) {
function msgRow(err, row) {
if(!err) {
msgList.push( {
id : row.message_id,
uuid : row.message_uuid,
replyToId : row.reply_to_message_id,
id : row.message_id,
uuid : row.message_uuid,
replyToId : row.reply_to_message_id,
toUsername : row.to_user_name,
fromUsername : row.from_user_name,
subject : row.subject,
timestamp : row.modified_timestamp,
viewCount : row.view_count,
} );
}
},
callback
);
},
function fetchStatus(callback) {
callback(null);// :TODO: fixmeh.
}
]
],
function complete(err) {
cb(err, msgList);
}
);
}

View File

@ -9,7 +9,6 @@ exports.pad = pad;
exports.replaceAt = replaceAt;
exports.isPrintable = isPrintable;
exports.debugEscapedString = debugEscapedString;
exports.format = format;
// :TODO: create Unicode verison of this
var VOWELS = [ 'a', 'e', 'i', 'o', 'u' ];

View File

@ -3,6 +3,7 @@
var MenuModule = require('../core/menu_module.js').MenuModule;
var ViewController = require('../core/view_controller.js').ViewController;
var messageArea = require('../core/message_area.js');
//var moment = require('moment');
var async = require('async');
@ -32,7 +33,7 @@ exports.moduleInfo = {
//
// Ideas
// * Module config can define custom formats for items & focused items (inc. Pipe Codes)
// * Single list view with advanced formatting (would need textOverflow stuff)
// * Single list view with advanced formatting (would need textOverflow stuff), advanced formatting...
// * Multiple LV's in sync with keyboard input
// * New Table LV (TV)
// *
@ -52,7 +53,7 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
var vc = self.viewControllers.msgList = new ViewController( { client : self.client } );
async.series(
async.waterfall(
[
function callParentMciReady(callback) {
MessageListModule.super_.prototype.mciReady.call(this, mciData, callback);
@ -66,10 +67,31 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
vc.loadFromMenuConfig(loadOpts, callback);
},
function fetchMessagesInArea(callback) {
messageArea.getMessageListForArea( { client : self.client }, self.client.user.properties.message_area_name, function msgs(err, msgList) {
callback(err, msgList);
});
},
function populateList(msgList, callback) {
var msgListView = vc.getView(1);
// :TODO: {name!over5}, ...over6, over7... -> "text..." for format()
var msgNum = 1;
msgListView.setItems(_.map(msgList, function formatMsgListEntry(mle) {
return '{msgNum} - {subj} {to}'.format( {
msgNum : msgNum++,
subj : mle.subject,
to : mle.to
} );
}));
msgListView.redraw();
}
],
function complete(err) {
if(err) {
console.log(err)
}
cb(err);
}
);