diff --git a/core/database.js b/core/database.js index 2240607a..be697168 100644 --- a/core/database.js +++ b/core/database.js @@ -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() { diff --git a/core/message.js b/core/message.js index cd8d4dfa..e3625e5e 100644 --- a/core/message.js +++ b/core/message.js @@ -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, ... diff --git a/core/message_area.js b/core/message_area.js index a3288f74..eb8c9874 100644 --- a/core/message_area.js +++ b/core/message_area.js @@ -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); + } ); } diff --git a/core/string_util.js b/core/string_util.js index 8aaae22a..f98d0d5a 100644 --- a/core/string_util.js +++ b/core/string_util.js @@ -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' ]; diff --git a/mods/msg_list.js b/mods/msg_list.js index 6a90083d..bc16589d 100644 --- a/mods/msg_list.js +++ b/mods/msg_list.js @@ -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); } );