1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 19:02:20 -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) {
// get OAuth token from chrome
appController.fetchOAuthToken(password, function(err) {
if (err) {
console.error(err);
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 offset = 0,
num = 100,
loggedIn = false;
firstSelect = true;
emailDao = appController._emailDao;
@ -73,6 +73,7 @@ define(function(require) {
//
function initList() {
firstSelect = true;
updateStatus('Read cache ...');
// list messaged from local db
@ -80,41 +81,12 @@ define(function(require) {
folder: getFolder().path,
offset: offset,
num: num
}, function() {
if (loggedIn) {
// user is already logged in
sync();
return;
}
// login to imap
loginImap(function() {
loggedIn = true;
sync();
});
});
function sync() {
}, function sync() {
updateStatus('Syncing ...');
$scope.$apply();
// sync imap folder to local db
$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) {
email.unread = false;
// only update imap state if user is logged in
if (!loggedIn) {
// don't mark top selected email automatically
if (firstSelect) {
firstSelect = false;
return;
}
email.unread = false;
emailDao.imapMarkMessageRead({
folder: getFolder().path,
uid: email.uid

View File

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