mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-08 20:26:20 +08:00
[local-sync] fix(folder-list): Support children when parent has no attribs
This commit is contained in:
parent
1e3b346c94
commit
aed1d59916
2 changed files with 165 additions and 147 deletions
|
@ -115,44 +115,53 @@
|
|||
}
|
||||
},
|
||||
"expectedFolders": [{
|
||||
"role": "trash",
|
||||
"name": "Trash"
|
||||
"name": "Trash",
|
||||
"role": "trash"
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "Taxes"
|
||||
"name": "Taxes",
|
||||
"role": null
|
||||
}, {
|
||||
"role": "spam",
|
||||
"name": "Spam"
|
||||
"name": "Spam",
|
||||
"role": "spam"
|
||||
}, {
|
||||
"role": "sent",
|
||||
"name": "Sent"
|
||||
"name": "Sent",
|
||||
"role": "sent"
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "Over the top"
|
||||
"name": "Over the top",
|
||||
"role": null
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "N1-Snoozed"
|
||||
"name": "N1-Snoozed",
|
||||
"role": null
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "JJJJJJJ JJJJJJJJ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"
|
||||
"name": "JJJJJJJ JJJJJJJJ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
|
||||
"role": null
|
||||
}, {
|
||||
"role": "drafts",
|
||||
"name": "Drafts"
|
||||
"name": "Housse/De/Rateau",
|
||||
"role": null
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "Boîte de réception"
|
||||
"name": "Housse/De/Bateau",
|
||||
"role": null
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "Arts"
|
||||
"name": "Fondue/Savoyarde",
|
||||
"role": null
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "Archive"
|
||||
"name": "Drafts",
|
||||
"role": "drafts"
|
||||
}, {
|
||||
"role": "inbox",
|
||||
"name": "INBOX"
|
||||
"name": "Boîte de réception",
|
||||
"role": null
|
||||
}, {
|
||||
"role": null,
|
||||
"name": "2016"
|
||||
"name": "Arts",
|
||||
"role": null
|
||||
}, {
|
||||
"name": "Archive",
|
||||
"role": null
|
||||
}, {
|
||||
"name": "INBOX",
|
||||
"role": "inbox"
|
||||
}, {
|
||||
"name": "2016",
|
||||
"role": null
|
||||
}],
|
||||
"expectedLabels": []
|
||||
}
|
||||
|
|
|
@ -66,16 +66,25 @@ class FetchFolderList {
|
|||
const next = [];
|
||||
|
||||
Object.keys(boxes).forEach((boxName) => {
|
||||
stack.push([boxName, boxes[boxName]]);
|
||||
stack.push([[boxName], boxes[boxName]]);
|
||||
});
|
||||
|
||||
while (stack.length > 0) {
|
||||
const [boxName, box] = stack.pop();
|
||||
const [boxPath, box] = stack.pop();
|
||||
|
||||
if (!box.attribs) {
|
||||
// Some boxes seem to come back as partial objects. Not sure why, but
|
||||
// I also can't access them via openMailbox. Possible node-imap i8n issue?
|
||||
if (box.children) {
|
||||
// In Fastmail, folders which are just containers for other folders
|
||||
// have no attributes at all, just a children property. Add appropriate
|
||||
// attribs so we can carry on.
|
||||
box.attribs = ['\\HasChildren', '\\NoSelect'];
|
||||
} else {
|
||||
// Some boxes seem to come back as partial objects. Not sure why.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const boxName = boxPath.join(box.delimiter);
|
||||
|
||||
this._logger.info({
|
||||
box_name: boxName,
|
||||
|
@ -85,7 +94,7 @@ class FetchFolderList {
|
|||
|
||||
if (box.children && box.attribs.includes('\\HasChildren')) {
|
||||
Object.keys(box.children).forEach((subname) => {
|
||||
stack.push([`${boxName}${box.delimiter}${subname}`, box.children[subname]]);
|
||||
stack.push([[].concat(boxPath, [subname]), box.children[subname]]);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue