1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 02:42:17 -05:00

displaying inbox message list works

This commit is contained in:
Tankred Hase 2013-09-11 23:31:08 +02:00
parent 3aac73ef2e
commit cb8314f9d0
6 changed files with 48 additions and 16 deletions

View File

@ -104,6 +104,10 @@
}
.subject {
font-weight: bold;
width: 13.571em;
height: 1em;
overflow: hidden;
display: inline-block;
}
.sent-date {
float: right;

View File

@ -1,7 +1,8 @@
define(function(require) {
'use strict';
var appController = require('js/app-controller'),
var _ = require('underscore'),
appController = require('js/app-controller'),
moment = require('moment');
var MessageListCtrl = function($scope, $routeParams) {
@ -23,7 +24,7 @@ define(function(require) {
});
};
if (true) {
if (false) {
createDummyMails(function(emails) {
$scope.emails = emails;
$scope.select($scope.emails[0]);
@ -38,14 +39,17 @@ define(function(require) {
};
function fetchList(callback) {
var folder = 'INBOX';
appController.fetchOAuthToken('passphrase', function(err) {
if (err) {
console.log(err);
return;
}
// fetch imap folder's message list
appController._emailDao.imapListMessages({
folder: 'INBOX',
folder: folder,
offset: -6,
num: 0
}, function(err, emails) {
@ -54,8 +58,34 @@ define(function(require) {
return;
}
addDisplayDate(emails);
callback(emails);
// fetch message bodies
fetchBodies(emails, folder, function(messages) {
addDisplayDate(messages);
callback(messages);
});
});
});
}
function fetchBodies(messageList, folder, callback) {
var emails = [];
var after = _.after(messageList.length, function() {
callback(emails);
});
_.each(messageList, function(messageItem) {
appController._emailDao.imapGetMessage({
folder: folder,
uid: messageItem.uid
}, function(err, message) {
if (err) {
console.log(err);
return;
}
emails.push(message);
after();
});
});
}

View File

@ -339,7 +339,7 @@ define(function(require) {
/* message was not found in cache... fetch from imap server */
function bodyReady(err, gottenMessage) {
function messageReady(err, gottenMessage) {
message = gottenMessage;
itemCounter++;
// remember how many items should be fetched before the callback fires
@ -431,10 +431,8 @@ define(function(require) {
self._imapClient.getMessage({
path: options.folder,
uid: options.uid,
onBody: bodyReady,
/*onAttachment: attachmentReady*/
onEnd: bodyReady
});
textOnly: true
}, messageReady);
};
/**

View File

@ -15,9 +15,9 @@
cordova: 'cordova-2.5.0',
ImapClient: 'imap-client-browserified',
SmtpClient: 'smtp-client-browserified',
angular: 'angular/angular',
angularRoute: 'angular/angular-route',
angularTouch: 'angular/angular-touch',
angular: 'angular/angular.min',
angularRoute: 'angular/angular-route.min',
angularTouch: 'angular/angular-touch.min',
moment: 'moment.min'
},
shim: {

View File

@ -13,10 +13,10 @@
<ul>
<li ng-repeat="email in emails" ng-class="{selected: email === selected}" ng-click="select(email)">
<div ng-class="{unread: email.unread, read: !email.unread}"></div>
<div ng-switch="email.attachments !== undefined">
<div ng-switch="email.attachments !== undefined && email.attachments.length > 0">
<div ng-switch-when="true" class="icon-attachment"></div>
</div>
<p class="from">{{email.from[0].name}}</p>
<p class="from">{{email.from[0].name || email.from[0].address}}</p>
<p class="subject-line">
<span class="subject">{{email.subject}}</span>
<span class="sent-date">{{email.displayDate}}</span>

View File

@ -287,7 +287,7 @@ define(function(require) {
it('should parse message body without attachement', function(done) {
var uid = 415;
imapClientStub.getMessage.yieldsTo('onBody', null, {
imapClientStub.getMessage.yields(null, {
uid: uid,
body: ''
});