Skip to content

Commit

Permalink
chore: Remove compatibility < 128
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Dec 12, 2024
1 parent fd8d0ef commit 1a1a69d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 86 deletions.
60 changes: 2 additions & 58 deletions src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,12 @@ ChromeUtils.defineModuleGetter(
"resource:///modules/UIFontSize.jsm"
);

const folderTypeMap = new Map([
[Ci.nsMsgFolderFlags.Inbox, "inbox"],
[Ci.nsMsgFolderFlags.Drafts, "drafts"],
[Ci.nsMsgFolderFlags.SentMail, "sent"],
[Ci.nsMsgFolderFlags.Trash, "trash"],
[Ci.nsMsgFolderFlags.Templates, "templates"],
[Ci.nsMsgFolderFlags.Archive, "archives"],
[Ci.nsMsgFolderFlags.Junk, "junk"],
[Ci.nsMsgFolderFlags.Queue, "outbox"],
]);

function convertFolder(folder, accountId) {
if (!folder) {
return null;
}
if (!accountId) {
let server = folder.server;
let acctMgr = MailServices.accounts;

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

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

let folderObject = {
accountId,
name: folder.prettyName,
path: folderURIToPath(folder.URI),
};

for (let [flag, typeName] of folderTypeMap.entries()) {
if (folder.flags & flag) {
folderObject.type = typeName;
}
}

return folderObject;
}

function folderURIToPath(uri) {
let path = Services.io.newURI(uri).filePath;
return path
.split("/")
.map(decodeURIComponent)
.join("/");
}

this.quickmove = class extends ExtensionAPI {
getAPI(context) {
return {
quickmove: {
// bug 1840039 - messenger.folders.query API
// Keeping this around as this verison allows us to switch between MRMTime and MRUTime
async query({ recent, limit, canFileMessages }) {
function* allFolders(root) {
if (
Expand All @@ -104,7 +56,7 @@ this.quickmove = class extends ExtensionAPI {
if (recent) {
let recentType = recent == "modified" ? "MRMTime" : "MRUTime";
let recentFolders = FolderUtils.getMostRecentFolders(folders, limit || Infinity, recentType);
folders = recentFolders.map(folder => convertFolder(folder));
folders = recentFolders.map(folder => context.extension.folderManager.convert(folder));
}

return folders;
Expand Down Expand Up @@ -137,14 +89,6 @@ 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");
tabmail.currentAbout3Pane?.threadTree.table.body.focus();
},

// bug 1849476 - messages.move/copy() doesn't set mail.last_msg_movecopy_target_uri
async setLastMoveCopyFolder({ accountId, path }, isMove) {
/* eslint-disable */
Expand Down
8 changes: 0 additions & 8 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@ async function processSelectedMessages(folder, operation="move", goToFolder=fals
return;
}

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


let messagePages;
if (tab.type == "messageDisplay") {
messagePages = [browser.messageDisplay.getDisplayedMessages(tab.id)];
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "115.0a1",
"strict_min_version": "128.0a1",
"strict_max_version": "135.*"
}
},
Expand Down
21 changes: 2 additions & 19 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ async function load() {
let fontSize = await messenger.quickmove.getUIFontSize();
window.document.documentElement.style.setProperty("font-size", `${fontSize}px`);

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

let {
maxRecentFolders, showFolderPath, skipArchive, layout, defaultFolderSetting, migratedShiftArrow,
recentStrategy
Expand Down Expand Up @@ -72,15 +69,8 @@ async function load() {
document.querySelector(".action-buttons").classList.add("hide");
}

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

// Setup folder list
let tags = await browser.messages.tags.list();
let accounts = await browser.accounts.list(true);

let [currentTab] = await browser.tabs.query({ currentWindow: true, active: true });
Expand Down Expand Up @@ -147,10 +137,8 @@ async function load() {
} else if (operation == "goto") {
let [tab] = await browser.tabs.query({ currentWindow: true, active: true });

// TB120 COMPAT
let folderId = majorVersion < 121 ? folder : folder.id;
try {
await browser.mailTabs.update(tab.id, { displayedFolder: folderId });
await browser.mailTabs.update(tab.id, { displayedFolder: folder.id });
} catch (e) {
if (e.message == "Requested folder is not viewable in any of the enabled folder modes") {
document.getElementById("tags-view-missing-warning").classList.remove("hidden");
Expand Down Expand Up @@ -196,10 +184,6 @@ async function load() {
switchList(action).focusSearch();
}

function unload(event) {
browser.runtime.sendMessage({ action: "focusThreadPane" }).catch(() => {});
}

function keydown(event) {
if (event.key == "Escape") {
window.close();
Expand Down Expand Up @@ -246,4 +230,3 @@ function keypress(event) {
window.addEventListener("keypress", keypress);
window.addEventListener("keydown", keydown, { capture: true });
window.addEventListener("DOMContentLoaded", load, { once: true });
window.addEventListener("unload", unload, { once: true, capture: true });

0 comments on commit 1a1a69d

Please sign in to comment.