Skip to content

Commit

Permalink
feat: Compatibility with Thunderbird 128
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Jul 15, 2024
1 parent 4807751 commit 47345b3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "quickmove",
"description": "Quick Folder Move",
"version": "2.8.1",
"version": "2.9.0",
"private": true,
"author": "Philipp Kewisch <[email protected]>",
"license": "MPL-2.0",
Expand Down
8 changes: 7 additions & 1 deletion src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function convertFolder(folder, accountId) {
}
if (!accountId) {
let server = folder.server;
let account = MailServices.accounts.FindAccountForServer(server);
let acctMgr = MailServices.accounts;

// TB115 COMPAT
let findAccountForServer = (acctMgr.findAccountForServer || acctMgr.FindAccountForServer).bind(acctMgr);

let account = findAccountForServer(server);
accountId = account.key;
}

Expand Down Expand Up @@ -127,6 +132,7 @@ this.quickmove = class extends ExtensionAPI {
},

// bug 1840072 - thread pane is not focused when returning from browserAction
// TB124 COMPAT - this can be removed in the next major release
async focusThreadPane(windowId) {
let window = Services.wm.getMostRecentWindow("mail:3pane");
let tabmail = window.top.document.getElementById("tabmail");
Expand Down
10 changes: 9 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ async function processSelectedMessages(folder, operation="move") {
return;
}

// TB120 COMPAT
let browserInfo = await browser.runtime.getBrowserInfo();
let folderId = folder.id;
if (parseInt(browserInfo.version.split(".")[0], 10) < 121) {
folderId = folder;
}


let messagePages;
if (tab.type == "messageDisplay") {
messagePages = [browser.messageDisplay.getDisplayedMessages(tab.id)];
Expand All @@ -67,7 +75,7 @@ async function processSelectedMessages(folder, operation="move") {
if (markAsRead) {
op = op.then(() => Promise.all(ids.map(id => browser.messages.update(id, { read: true }))));
}
op = op.then(() => browser.messages[operation](ids, folder));
op = op.then(() => browser.messages[operation](ids, folderId));
ops.push(op);
}

Expand Down
9 changes: 6 additions & 3 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"manifest_version": 2,
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "2.8.1",
"version": "2.9.0",
"default_locale": "en",
"author": "Philipp Kewisch",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "115.0a1",
"strict_max_version": "120.*"
"strict_max_version": "128.*"
}
},
"icons": {
Expand All @@ -29,7 +29,10 @@
"storage",
"accountsRead",
"messagesRead",
"messagesMove"
"messagesMove",
"messagesTags",
"messagesTagsList",
"messagesUpdate"
],
"browser_action": {
"default_icon": "images/addon.svg",
Expand Down
26 changes: 23 additions & 3 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function switchList(action) {
}

async function load() {
// TB120 COMPAT
let majorVersion = parseInt((await browser.runtime.getBrowserInfo()).version.split(".")[0], 10);

let { maxRecentFolders, showFolderPath, skipArchive, layout, defaultFolderSetting } = await browser.storage.local.get({ maxRecentFolders: 15, showFolderPath: true, layout: "auto", skipArchive: true, defaultFolderSetting: "recent" });

if (layout == "wide" || (layout == "auto" && window.outerWidth > 1400)) {
Expand Down Expand Up @@ -88,7 +91,14 @@ async function load() {
let defaultFolders;

if (defaultFolderSetting == "recent") {
defaultFolders = FolderNode.fromList(await browser.quickmove.query({ recent: true, limit: maxRecentFolders, canFileMessages: true }), accountNodes);
let folderList;
if (majorVersion < 121) {
// TB120 COMPAT
folderList = await browser.quickmove.query({ recent: true, limit: maxRecentFolders, canFileMessages: true });
} else {
folderList = await browser.folders.query({ recent: true, limit: maxRecentFolders, canAddMessages: true });
}
defaultFolders = FolderNode.fromList(folderList, accountNodes);
} else if (defaultFolderSetting == "specific") {
defaultFolders = FolderNode.fromList(await getValidatedDefaultFolders(accountNodes), accountNodes);
} else {
Expand All @@ -106,13 +116,23 @@ async function load() {
await browser.runtime.sendMessage({ action: "processSelectedMessages", folder: event.detail, operation: operation });
} else if (operation == "goto") {
let [tab] = await browser.tabs.query({ currentWindow: true, active: true });
await browser.mailTabs.update(tab.id, { displayedFolder: event.detail });

// TB120 COMPAT
let folderId = majorVersion < 121 ? event.detail : event.detail.id;
await browser.mailTabs.update(tab.id, { displayedFolder: folderId });
}
window.close();
});

// Setup tag list
let tags = await browser.messages.listTags();
// TB120 COMPAT
let tags;
if (majorVersion < 121) {
tags = await browser.messages.listTags();
} else {
tags = await browser.messages.tags.list();
}

let tagList = document.getElementById("tag-list");
tagList.ignoreFocus = true;
tagList.initItems(tags, null);
Expand Down

0 comments on commit 47345b3

Please sign in to comment.