mirror of
https://github.com/moparisthebest/mail
synced 2024-10-31 15:25:01 -04:00
Merge pull request #185 from whiteout-io/dev/wo-731
[WO-731] Treat modseq values as numbers
This commit is contained in:
commit
21356ae9ac
@ -1154,7 +1154,7 @@ EmailDAO.prototype.onConnect = function(options, callback) {
|
|||||||
self._imapClient.onSyncUpdate = self._onSyncUpdate.bind(self);
|
self._imapClient.onSyncUpdate = self._onSyncUpdate.bind(self);
|
||||||
|
|
||||||
// fill the imap mailboxCache with information we have locally available:
|
// fill the imap mailboxCache with information we have locally available:
|
||||||
// - highest locally available moseq
|
// - highest locally available moseq (NB! JavaScript can't handle 64 bit uints, so modseq values are strings)
|
||||||
// - list of locally available uids
|
// - list of locally available uids
|
||||||
// - highest locally available uid
|
// - highest locally available uid
|
||||||
// - next expected uid
|
// - next expected uid
|
||||||
@ -1172,8 +1172,13 @@ EmailDAO.prototype.onConnect = function(options, callback) {
|
|||||||
lastUid = uids[uids.length - 1];
|
lastUid = uids[uids.length - 1];
|
||||||
|
|
||||||
highestModseq = _.pluck(folder.messages, 'modseq').sort(function(a, b) {
|
highestModseq = _.pluck(folder.messages, 'modseq').sort(function(a, b) {
|
||||||
return a - b;
|
// We treat modseq values as numbers here as an exception, should
|
||||||
}).pop();
|
// be strings everywhere else.
|
||||||
|
// If it turns out that someone actually uses 64 bit uint numbers
|
||||||
|
// that do not fit to the JavaScript number type then we should
|
||||||
|
// use a helper for handling big integers.
|
||||||
|
return (Number(a) || 0) - (Number(b) || 0);
|
||||||
|
}).pop().toString();
|
||||||
|
|
||||||
mailboxCache[folder.path] = {
|
mailboxCache[folder.path] = {
|
||||||
exists: lastUid,
|
exists: lastUid,
|
||||||
|
@ -910,7 +910,7 @@ describe('Email DAO unit tests', function() {
|
|||||||
var localListStub, localStoreStub, imapGetStub, uid;
|
var localListStub, localStoreStub, imapGetStub, uid;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
uid = 12345,
|
uid = 12345;
|
||||||
localListStub = sinon.stub(dao, '_localListMessages');
|
localListStub = sinon.stub(dao, '_localListMessages');
|
||||||
localStoreStub = sinon.stub(dao, '_localStoreMessages');
|
localStoreStub = sinon.stub(dao, '_localStoreMessages');
|
||||||
imapGetStub = sinon.stub(dao, '_getBodyParts');
|
imapGetStub = sinon.stub(dao, '_getBodyParts');
|
||||||
@ -1842,7 +1842,7 @@ describe('Email DAO unit tests', function() {
|
|||||||
it('should connect', function(done) {
|
it('should connect', function(done) {
|
||||||
inboxFolder.messages = [{
|
inboxFolder.messages = [{
|
||||||
uid: 123,
|
uid: 123,
|
||||||
modseq: 123
|
modseq: '123'
|
||||||
}];
|
}];
|
||||||
imapClientStub.login.yieldsAsync();
|
imapClientStub.login.yieldsAsync();
|
||||||
imapClientStub.listenForChanges.yieldsAsync();
|
imapClientStub.listenForChanges.yieldsAsync();
|
||||||
@ -1862,7 +1862,7 @@ describe('Email DAO unit tests', function() {
|
|||||||
exists: 123,
|
exists: 123,
|
||||||
uidNext: 124,
|
uidNext: 124,
|
||||||
uidlist: [123],
|
uidlist: [123],
|
||||||
highestModseq: 123
|
highestModseq: '123'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user