This commit is contained in:
Ximi1970
2023-10-21 13:53:59 +02:00
parent f0d71ff1c5
commit 6df32d4ead
2 changed files with 4 additions and 96 deletions

View File

@@ -13,32 +13,6 @@ function getFolderTree(mailAccounts, browserInfo) {
} }
} }
function createFolderTreePre74(accountName, folders) {
let result = [];
let level = { result };
folders.forEach((folder) => {
folder.path
.slice(1)
.split("/")
.reduce((r, name, i, a) => {
if (!r[name]) {
r[name] = { result: [] };
r.result.push({
accountId: folder.accountId,
name: folder.name,
subFolders: r[name].result,
});
}
return r[name];
}, level);
});
traverse(accountName, "", result);
return result;
}
function createFolderTree(accountName, folders) { function createFolderTree(accountName, folders) {
traverse(accountName, "", folders); traverse(accountName, "", folders);
return folders; return folders;
@@ -82,20 +56,10 @@ function getFolderTree(mailAccounts, browserInfo) {
if (accounts[prop]) { if (accounts[prop]) {
for (let i = 0; i < accounts[prop].length; ++i) { for (let i = 0; i < accounts[prop].length; ++i) {
// Create a usable folder tree // Create a usable folder tree
let folders = []; const folders = createFolderTree(
if (browserInfo.version.split(".")[0] < 74) { accounts[prop][i].name,
// Pre TB74 accounts API accounts[prop][i].folders
folders = createFolderTreePre74( );
accounts[prop][i].name,
accounts[prop][i].folders
);
} else {
// TB74+ accounts API, (this shit never ends...)
folders = createFolderTree(
accounts[prop][i].name,
accounts[prop][i].folders
);
}
// Store the tree // Store the tree
folderTree[accounts[prop][i].name] = folders; folderTree[accounts[prop][i].name] = folders;

View File

@@ -25,62 +25,6 @@ SysTrayX.Accounts = {
}, },
buildTree: function (mailAccount) { buildTree: function (mailAccount) {
function createFolderTreePre74(accountName, folders) {
let result = [];
let level = { result };
folders.forEach((folder) => {
folder.path
.slice(1)
.split("/")
.reduce((r, name, i, a) => {
if (!r[name]) {
r[name] = { result: [] };
r.result.push({
accountId: folder.accountId,
name: folder.name,
type: folder.type,
subFolders: r[name].result,
});
}
return r[name];
}, level);
});
function traverse(path, folders) {
if (!folders) {
return;
}
for (let f of folders) {
f.accountName = accountName;
f.path = path + "/" + f.name;
traverse(path + "/" + f.name, f.subFolders);
}
}
traverse("", result);
return result;
}
function createFolderTreePre91(accountName, folders) {
function traverse(path, folders) {
if (!folders) {
return;
}
for (let f of folders) {
f.accountName = accountName;
f.path = path + "/" + f.name;
traverse(path + "/" + f.name, f.subFolders);
}
}
traverse("", folders);
return folders;
}
function createFolderTree(accountName, folders) { function createFolderTree(accountName, folders) {
function traverse(folders) { function traverse(folders) {
if (!folders) { if (!folders) {