mirror of
https://github.com/moparisthebest/mail
synced 2024-12-22 15:28:49 -05:00
add unread counts to folders
This commit is contained in:
parent
18fe55af7a
commit
4029627c40
@ -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
|
||||
|
@ -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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user