2013-09-04 15:01:32 -04:00
|
|
|
define(function(require) {
|
2013-09-04 12:39:26 -04:00
|
|
|
'use strict';
|
|
|
|
|
2013-09-04 15:01:32 -04:00
|
|
|
var appController = require('js/app-controller');
|
2013-09-04 12:39:26 -04:00
|
|
|
|
|
|
|
var MessageListCtrl = function($scope) {
|
|
|
|
$scope.folderName = 'Inbox';
|
|
|
|
|
|
|
|
$scope.select = function(email) {
|
|
|
|
$scope.selected = email;
|
|
|
|
};
|
2013-09-04 15:01:32 -04:00
|
|
|
|
|
|
|
fetchList(function(err, emails) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.emails = emails;
|
|
|
|
$scope.$apply();
|
|
|
|
});
|
2013-09-04 12:39:26 -04:00
|
|
|
};
|
|
|
|
|
2013-09-04 15:01:32 -04:00
|
|
|
function fetchList(callback) {
|
|
|
|
appController.fetchOAuthToken('passphrase', function(err) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
appController._emailDao.imapListMessages({
|
|
|
|
folder: 'INBOX',
|
|
|
|
offset: -6,
|
|
|
|
num: 0
|
|
|
|
}, callback);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-09-04 12:39:26 -04:00
|
|
|
return MessageListCtrl;
|
|
|
|
});
|