Fix deprecated methods

This commit is contained in:
Ximi1970
2024-04-05 14:06:09 +02:00
parent 8bb226ac18
commit e3d66e29ab
2 changed files with 37 additions and 14 deletions

View File

@@ -8,20 +8,34 @@ SysTrayX.Accounts = {
},
getAccounts: async function () {
let accounts;
if (SysTrayX.Info.browserInfo.majorVersion < 121) {
let accounts;
accounts = await browser.accounts.list(false);
accounts = await browser.accounts.list(false);
// Fill the sub folders using the folders API, they are not same...
for (let i = 0; i < accounts.length; ++i) {
const subFolders = await browser.folders.getSubFolders(
accounts[i],
true
);
accounts[i].folders = subFolders;
// Fill the sub folders using the folders API, they are not same...
for (let i = 0; i < accounts.length; ++i) {
const subFolders = await browser.folders.getSubFolders(
accounts[i],
true
);
accounts[i].folders = subFolders;
}
return accounts;
} else {
let accounts = await browser.accounts.list();
for (let i = 0; i < accounts.length; ++i) {
const subFolders = await browser.folders.getSubFolders(
accounts[i].id,
true
);
accounts[i].folders = subFolders;
}
return accounts;
}
return accounts;
},
buildTree: function (mailAccount) {

View File

@@ -1233,7 +1233,16 @@ SysTrayX.RestoreOptions = {
)
);
filter.folders.forEach((path) => {
filter.folders.forEach((storedFolder) => {
if (typeof(storedFolder) === "string") {
// Filters pre TB 121
path = storedFolder;
} else {
// Filters TB 121
path = storedFolder.path;
}
checkboxes.forEach((checkbox) => {
const value = JSON.parse(checkbox.value);
if (value.path === path) {
@@ -1539,8 +1548,8 @@ async function start() {
browser.storage.onChanged.addListener(SysTrayX.StorageChanged.changed);
document.addEventListener("visibilitychange", function () {
if (document.visibilityState === "hidden") {
browser.storage.onChanged.removeListener(SysTrayX.StorageChanged.changed);
if ( browser.storage.onChanged.hasListener(SysTrayX.StorageChanged.changed) ) {
browser.storage.onChanged.removeListener(SysTrayX.StorageChanged.changed);
}
});
}