diff --git a/lib/handlers/on-open.js b/lib/handlers/on-open.js index 53af3f39..fbeb6091 100644 --- a/lib/handlers/on-open.js +++ b/lib/handlers/on-open.js @@ -34,12 +34,13 @@ module.exports = server => (path, session, callback) => { .project({ uid: true }) - .sort([['uid', 1]]) + //.sort([['uid', 1]]) .toArray((err, messages) => { if (err) { return callback(err); } - mailbox.uidList = messages.map(message => message.uid).sort((a, b) => a.uid - b.uid); + // sort and ensure unique UIDs + mailbox.uidList = Array.from(new Set(messages.map(message => message.uid))).sort((a, b) => a - b); callback(null, mailbox); }); }