diff --git a/lib/imap.js b/lib/imap.js index 5a2bbb7..f4054ad 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -71,7 +71,7 @@ function ImapConnection (options) { keywords: [], permFlags: [], name: null, - messages: { total: 0, new: 0 } + messages: { total: 0, new: 0, unseen: 0 } }, ext: { // Capability-specific state info @@ -468,7 +468,7 @@ ImapConnection.prototype.connect = function(loginCb) { self.emit('alert', m[3]); else if (state.status === STATES.BOXSELECTING) { if (m = /^UNSEEN (\d+)/i.exec(code)) - state.box.unseen = m[1]; + state.box.messages.unseen = parseInt(m[1], 10); else if (m = /^UIDVALIDITY (\d+)/i.exec(code)) state.box.uidvalidity = m[1]; else if (m = /^UIDNEXT (\d+)/i.exec(code)) @@ -1244,6 +1244,7 @@ ImapConnection.prototype._resetBox = function() { this._state.box.name = null; this._state.box.messages.total = 0; this._state.box.messages.new = 0; + this._state.box.messages.unseen = 0; }; ImapConnection.prototype._noop = function() {