Skip to content
Browse files

Updated folder handling

  • Loading branch information...
1 parent f4540c7 commit c86f0a09b6d63a049c19c5b139722a320fb225bf Andris Reinman committed
Showing with 20 additions and 3 deletions.
  1. +19 −2 lib/client.js
  2. +1 −1 package.json
View
21 lib/client.js
@@ -1342,7 +1342,6 @@ IMAPClient.prototype._formatEnvelope = function(envelopeData){
return label.split(this._mailboxDelimiter).map(function(localLabel){
var localType;
if((localType = detectMailboxType(localLabel)) != "Normal"){
- // Add flag indicator
messageTypes.push(localType);
return localLabel;
}else{
@@ -1351,16 +1350,19 @@ IMAPClient.prototype._formatEnvelope = function(envelopeData){
});
}
+ // Convert name to canonized version
if((type = detectMailboxType(label)) != "Normal"){
// Add flag indicator
messageTypes.push(type);
return type;
}
- if(label.charAt(0)=="\\"){
+ // Convert tags to names
+ if(label.charAt(0)=="\\" && label != "\\Important"){
label = label.substr(1);
messageTypes.push(label);
}
+
return label;
}).bind(this));
}else{
@@ -1381,6 +1383,21 @@ IMAPClient.prototype._formatEnvelope = function(envelopeData){
}).bind(this));
}
}
+
+ // remove duplicates
+ if(message.folders){
+ var folderList = [];
+ for(var i=0, len=message.folders.length; i<len; i++){
+ if((folderList.indexOf(message.folders[i]) < 0) && (message.folders[i] != "\\Important")){
+ folderList.push(message.folders[i]);
+ }
+ }
+ message.folders = folderList;
+
+ if(!message.folders.length){
+ message.folders = ["Inbox"];
+ }
+ }
messageTypes = messageTypes.map(function(type){
return messageTypeMap[type] || type;
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "inbox",
- "version": "0.1.25",
+ "version": "0.1.26",
"author" : "Andris Reinman",
"maintainers":[
{

0 comments on commit c86f0a0

Please sign in to comment.
Something went wrong with that request. Please try again.