mirror of
https://github.com/moparisthebest/mail
synced 2024-11-22 17:02:17 -05:00
displaying inbox message list works
This commit is contained in:
parent
3aac73ef2e
commit
cb8314f9d0
@ -104,6 +104,10 @@
|
||||
}
|
||||
.subject {
|
||||
font-weight: bold;
|
||||
width: 13.571em;
|
||||
height: 1em;
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
}
|
||||
.sent-date {
|
||||
float: right;
|
||||
|
@ -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,9 +58,35 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
addDisplayDate(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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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: {
|
||||
|
@ -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>
|
||||
|
@ -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: ''
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user