1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-30 04:42:15 -05:00

Merge branch 'new_ui' into pgp

This commit is contained in:
Tankred Hase 2013-10-11 23:29:07 +02:00
commit 271e218868
3 changed files with 18 additions and 37 deletions

View File

@ -21,13 +21,22 @@ define(function(require) {
}); });
function login(password, callback) { function login(password, callback) {
// get OAuth token from chrome
appController.fetchOAuthToken(password, function(err) { appController.fetchOAuthToken(password, function(err) {
if (err) { if (err) {
console.error(err); console.error(err);
return; return;
} }
callback(); // login to imap backend
appController._emailDao.imapLogin(function(err) {
if (err) {
console.error(err);
return;
}
callback();
});
}); });
} }

View File

@ -8,7 +8,7 @@ define(function(require) {
var MailListCtrl = function($scope) { var MailListCtrl = function($scope) {
var offset = 0, var offset = 0,
num = 100, num = 100,
loggedIn = false; firstSelect = true;
emailDao = appController._emailDao; emailDao = appController._emailDao;
@ -73,6 +73,7 @@ define(function(require) {
// //
function initList() { function initList() {
firstSelect = true;
updateStatus('Read cache ...'); updateStatus('Read cache ...');
// list messaged from local db // list messaged from local db
@ -80,41 +81,12 @@ define(function(require) {
folder: getFolder().path, folder: getFolder().path,
offset: offset, offset: offset,
num: num num: num
}, function() { }, function sync() {
if (loggedIn) {
// user is already logged in
sync();
return;
}
// login to imap
loginImap(function() {
loggedIn = true;
sync();
});
});
function sync() {
updateStatus('Syncing ...'); updateStatus('Syncing ...');
$scope.$apply(); $scope.$apply();
// sync imap folder to local db // sync imap folder to local db
$scope.synchronize(); $scope.synchronize();
}
}
function loginImap(callback) {
updateStatus('Login ...');
$scope.$apply();
emailDao.imapLogin(function(err) {
if (err) {
console.log(err);
updateStatus('Error on login!');
$scope.$apply();
return;
}
callback();
}); });
} }
@ -187,13 +159,13 @@ define(function(require) {
} }
function markAsRead(email) { function markAsRead(email) {
email.unread = false; // don't mark top selected email automatically
if (firstSelect) {
// only update imap state if user is logged in firstSelect = false;
if (!loggedIn) {
return; return;
} }
email.unread = false;
emailDao.imapMarkMessageRead({ emailDao.imapMarkMessageRead({
folder: getFolder().path, folder: getFolder().path,
uid: email.uid uid: email.uid

View File

@ -11,9 +11,9 @@ define(function(require) {
initFolders(function(folders) { initFolders(function(folders) {
$scope.folders = folders; $scope.folders = folders;
$scope.apply();
// select inbox as the current folder on init // select inbox as the current folder on init
$scope.openFolder($scope.folders[0]); $scope.openFolder($scope.folders[0]);
$scope.$apply();
}); });
// //