mirror of
https://github.com/moparisthebest/mail
synced 2024-11-29 20:32:15 -05:00
Merge remote-tracking branch 'origin/dev/unread-count'
This commit is contained in:
commit
c2853df8aa
@ -75,6 +75,12 @@ define(function(require) {
|
|||||||
return;
|
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;
|
self._account.folders = folders;
|
||||||
callback(null, keypair);
|
callback(null, keypair);
|
||||||
});
|
});
|
||||||
@ -484,15 +490,21 @@ define(function(require) {
|
|||||||
// we have a mismatch concerning flags between imap and memory.
|
// we have a mismatch concerning flags between imap and memory.
|
||||||
// pull changes from imap.
|
// pull changes from imap.
|
||||||
function doDeltaF4() {
|
function doDeltaF4() {
|
||||||
if (_.isEmpty(deltaF4)) {
|
function finishSync() {
|
||||||
self._account.busy = false;
|
self._account.busy = false;
|
||||||
|
folder.count = _.filter(folder.messages, function(msg) {
|
||||||
|
return msg.unread === true;
|
||||||
|
}).length;
|
||||||
callback();
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_.isEmpty(deltaF4)) {
|
||||||
|
finishSync();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var after = _.after(deltaF4.length, function() {
|
var after = _.after(deltaF4.length, function() {
|
||||||
self._account.busy = false;
|
finishSync();
|
||||||
callback();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// deltaF4 contains the imap headers that have changed flags
|
// deltaF4 contains the imap headers that have changed flags
|
||||||
|
@ -131,7 +131,7 @@ define(function(require) {
|
|||||||
it('should init', function(done) {
|
it('should init', function(done) {
|
||||||
var loginStub, listFolderStub, folders;
|
var loginStub, listFolderStub, folders;
|
||||||
|
|
||||||
folders = [];
|
folders = [{}, {}];
|
||||||
|
|
||||||
// initKeychain
|
// initKeychain
|
||||||
devicestorageStub.init.withArgs(emailAddress).yields();
|
devicestorageStub.init.withArgs(emailAddress).yields();
|
||||||
@ -151,6 +151,7 @@ define(function(require) {
|
|||||||
|
|
||||||
expect(dao._account).to.equal(account);
|
expect(dao._account).to.equal(account);
|
||||||
expect(dao._account.folders).to.equal(folders);
|
expect(dao._account.folders).to.equal(folders);
|
||||||
|
expect(dao._account.folders[0].count).to.equal(0);
|
||||||
expect(devicestorageStub.init.calledOnce).to.be.true;
|
expect(devicestorageStub.init.calledOnce).to.be.true;
|
||||||
expect(keychainStub.getUserKeyPair.calledOnce).to.be.true;
|
expect(keychainStub.getUserKeyPair.calledOnce).to.be.true;
|
||||||
|
|
||||||
@ -600,6 +601,8 @@ define(function(require) {
|
|||||||
type: 'Folder',
|
type: 'Folder',
|
||||||
path: folder
|
path: folder
|
||||||
}];
|
}];
|
||||||
|
dummyDecryptedMail.unread = true;
|
||||||
|
dummyEncryptedMail.unread = true;
|
||||||
|
|
||||||
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
|
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
|
||||||
folder: folder
|
folder: folder
|
||||||
@ -631,6 +634,7 @@ define(function(require) {
|
|||||||
expect(localListStub.calledOnce).to.be.true;
|
expect(localListStub.calledOnce).to.be.true;
|
||||||
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;
|
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;
|
||||||
expect(pgpStub.decrypt.calledOnce).to.be.true;
|
expect(pgpStub.decrypt.calledOnce).to.be.true;
|
||||||
|
expect(dao._account.folders[0].count).to.equal(1);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -673,6 +677,8 @@ define(function(require) {
|
|||||||
path: folder
|
path: folder
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
dummyEncryptedMail.unread = true;
|
||||||
|
|
||||||
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
|
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
|
||||||
folder: folder
|
folder: folder
|
||||||
}).yields(null, []);
|
}).yields(null, []);
|
||||||
@ -706,6 +712,7 @@ define(function(require) {
|
|||||||
expect(localStoreStub.calledOnce).to.be.true;
|
expect(localStoreStub.calledOnce).to.be.true;
|
||||||
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;
|
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;
|
||||||
expect(pgpStub.decrypt.calledOnce).to.be.true;
|
expect(pgpStub.decrypt.calledOnce).to.be.true;
|
||||||
|
expect(dao._account.folders[0].count).to.equal(1);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user