From 47345b32b096988f7a821ca9a8d77002c85aa428 Mon Sep 17 00:00:00 2001 From: Philipp Kewisch Date: Mon, 15 Jul 2024 20:21:23 +0200 Subject: [PATCH] feat: Compatibility with Thunderbird 128 --- package-lock.json | 2 +- package.json | 2 +- src/api/api.js | 8 +++++++- src/background.js | 10 +++++++++- src/manifest.json | 9 ++++++--- src/popup/popup.js | 26 +++++++++++++++++++++++--- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index b15ddc4..799c8f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "quickmove", - "version": "2.8.1", + "version": "2.9.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 2f9788c..427876c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "quickmove", "description": "Quick Folder Move", - "version": "2.8.1", + "version": "2.9.0", "private": true, "author": "Philipp Kewisch ", "license": "MPL-2.0", diff --git a/src/api/api.js b/src/api/api.js index 77b7cd9..e894f89 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -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; } @@ -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"); diff --git a/src/background.js b/src/background.js index e20efd4..1d42b29 100644 --- a/src/background.js +++ b/src/background.js @@ -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)]; @@ -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); } diff --git a/src/manifest.json b/src/manifest.json index 16ac107..f8ec8f1 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -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": "quickmove@mozilla.kewis.ch", "strict_min_version": "115.0a1", - "strict_max_version": "120.*" + "strict_max_version": "128.*" } }, "icons": { @@ -29,7 +29,10 @@ "storage", "accountsRead", "messagesRead", - "messagesMove" + "messagesMove", + "messagesTags", + "messagesTagsList", + "messagesUpdate" ], "browser_action": { "default_icon": "images/addon.svg", diff --git a/src/popup/popup.js b/src/popup/popup.js index 836070e..ef3f070 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -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)) { @@ -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 { @@ -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);