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

mails in outbox are correctly displayed

This commit is contained in:
Felix Hammerl 2013-12-04 17:13:45 +01:00
parent 1714955e8e
commit 9e41626182
3 changed files with 23 additions and 4 deletions

View File

@ -224,7 +224,11 @@ define(function(require) {
self._emailDao.init({ self._emailDao.init({
account: account account: account
}, callback); }, function(err, keypair) {
self._outboxBo.init();
callback(err, keypair);
});
} }
}; };

View File

@ -37,6 +37,13 @@ define(function(require) {
this.pendingEmails = []; this.pendingEmails = [];
}; };
OutboxBO.prototype.init = function() {
var outboxFolder = _.findWhere(this._emailDao._account.folders, {
type: 'Outbox'
});
outboxFolder.messages = this.pendingEmails;
};
/** /**
* This function activates the periodic checking of the local device storage for pending mails. * This function activates the periodic checking of the local device storage for pending mails.
* @param {Function} callback(error, pendingMailsCount) Callback that informs you about the count of pending mails. * @param {Function} callback(error, pendingMailsCount) Callback that informs you about the count of pending mails.
@ -89,8 +96,11 @@ define(function(require) {
// update outbox folder count // update outbox folder count
emails = pending; emails = pending;
// keep an independent shallow copy of the pending mails array in the member // fill all the pending mails into the pending mails array
self.pendingEmails = pending.slice(); self.pendingEmails.length = 0; //fastest way to empty an array
pending.forEach(function(i) {
self.pendingEmails.push(i);
});
// sending pending mails // sending pending mails
processMails(); processMails();

View File

@ -16,12 +16,16 @@ define(function(require) {
beforeEach(function() { beforeEach(function() {
emailDaoStub = sinon.createStubInstance(EmailDAO); emailDaoStub = sinon.createStubInstance(EmailDAO);
emailDaoStub._account = { emailDaoStub._account = {
emailAddress: dummyUser emailAddress: dummyUser,
folders: [{
type: 'Outbox'
}]
}; };
devicestorageStub = sinon.createStubInstance(DeviceStorageDAO); devicestorageStub = sinon.createStubInstance(DeviceStorageDAO);
keychainStub = sinon.createStubInstance(KeychainDAO); keychainStub = sinon.createStubInstance(KeychainDAO);
invitationDaoStub = sinon.createStubInstance(InvitationDAO); invitationDaoStub = sinon.createStubInstance(InvitationDAO);
outbox = new OutboxBO(emailDaoStub, keychainStub, devicestorageStub, invitationDaoStub); outbox = new OutboxBO(emailDaoStub, keychainStub, devicestorageStub, invitationDaoStub);
outbox.init();
}); });
afterEach(function() {}); afterEach(function() {});
@ -35,6 +39,7 @@ define(function(require) {
expect(outbox._invitationDao).to.equal(invitationDaoStub); expect(outbox._invitationDao).to.equal(invitationDaoStub);
expect(outbox._outboxBusy).to.be.false; expect(outbox._outboxBusy).to.be.false;
expect(outbox.pendingEmails).to.be.empty; expect(outbox.pendingEmails).to.be.empty;
expect(emailDaoStub._account.folders[0].messages).to.equal(outbox.pendingEmails);
}); });
}); });