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

integrate mark email as read

This commit is contained in:
Tankred Hase 2013-10-04 17:02:27 +02:00
parent 7b695d3449
commit 82d592f0cc
3 changed files with 59 additions and 2 deletions

View File

@ -23,6 +23,9 @@ define(function(require) {
$scope.selected = email;
// set selected in parent scope ro it can be displayed in the read view
$scope.$parent.selected = $scope.selected;
// mark selected message as 'read'
markAsRead(email);
};
$scope.synchronize = function() {
@ -175,6 +178,27 @@ define(function(require) {
function getFolder() {
return $scope.$parent.currentFolder;
}
function markAsRead(email) {
email.unread = false;
// only update imap state if user is logged in
if (!loggedIn) {
return;
}
emailDao.imapMarkMessageRead({
folder: getFolder().path,
uid: email.uid
}, function(err) {
if (err) {
console.log(err);
updateStatus('Error marking read!');
$scope.$apply();
return;
}
});
}
};
function createDummyMails(callback) {

View File

@ -384,6 +384,24 @@ define(function(require) {
}, messageReady);
};
EmailDAO.prototype.imapMarkMessageRead = function(options, callback) {
var self = this;
// validate options
if (!options.folder || !options.uid) {
callback({
errMsg: 'Invalid options!'
});
return;
}
self._imapClient.updateFlags({
path: options.folder,
uid: options.uid,
unread: false
}, callback);
};
//
// SMTP Apis
//

View File

@ -228,7 +228,7 @@ define(function(require) {
});
});
describe('IMAP: get unread messages for folder', function() {
describe('IMAP: get unread message count for folder', function() {
it('should work', function(done) {
imapClientStub.unreadMessages.yields();
emailDao.unreadMessages(function(err) {
@ -409,8 +409,23 @@ define(function(require) {
});
});
});
});
describe('IMAP: mark message as read', function() {
it('should work', function(done) {
imapClientStub.updateFlags.yields();
emailDao.imapMarkMessageRead({
folder: 'asdf',
uid: 1
}, function(err) {
expect(imapClientStub.updateFlags.calledOnce).to.be.true;
expect(err).to.not.exist;
done();
});
});
});
});
});