1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 19:02:20 -05:00

Merge remote-tracking branch 'origin/dev/unread-count'

This commit is contained in:
Tankred Hase 2013-12-06 18:02:36 +01:00
commit c2853df8aa
2 changed files with 23 additions and 4 deletions

View File

@ -75,6 +75,12 @@ define(function(require) {
return;
}
// every folder is initially created with an unread count of 0.
// the unread count will be updated after every sync
folders.forEach(function(folder){
folder.count = 0;
});
self._account.folders = folders;
callback(null, keypair);
});
@ -484,15 +490,21 @@ define(function(require) {
// we have a mismatch concerning flags between imap and memory.
// pull changes from imap.
function doDeltaF4() {
if (_.isEmpty(deltaF4)) {
function finishSync() {
self._account.busy = false;
folder.count = _.filter(folder.messages, function(msg) {
return msg.unread === true;
}).length;
callback();
}
if (_.isEmpty(deltaF4)) {
finishSync();
return;
}
var after = _.after(deltaF4.length, function() {
self._account.busy = false;
callback();
finishSync();
});
// deltaF4 contains the imap headers that have changed flags

View File

@ -131,7 +131,7 @@ define(function(require) {
it('should init', function(done) {
var loginStub, listFolderStub, folders;
folders = [];
folders = [{}, {}];
// initKeychain
devicestorageStub.init.withArgs(emailAddress).yields();
@ -151,6 +151,7 @@ define(function(require) {
expect(dao._account).to.equal(account);
expect(dao._account.folders).to.equal(folders);
expect(dao._account.folders[0].count).to.equal(0);
expect(devicestorageStub.init.calledOnce).to.be.true;
expect(keychainStub.getUserKeyPair.calledOnce).to.be.true;
@ -600,6 +601,8 @@ define(function(require) {
type: 'Folder',
path: folder
}];
dummyDecryptedMail.unread = true;
dummyEncryptedMail.unread = true;
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder
@ -631,6 +634,7 @@ define(function(require) {
expect(localListStub.calledOnce).to.be.true;
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;
expect(pgpStub.decrypt.calledOnce).to.be.true;
expect(dao._account.folders[0].count).to.equal(1);
done();
});
@ -673,6 +677,8 @@ define(function(require) {
path: folder
}];
dummyEncryptedMail.unread = true;
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder
}).yields(null, []);
@ -706,6 +712,7 @@ define(function(require) {
expect(localStoreStub.calledOnce).to.be.true;
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;
expect(pgpStub.decrypt.calledOnce).to.be.true;
expect(dao._account.folders[0].count).to.equal(1);
done();
});