Skip to content

Commit

Permalink
ESR115 support
Browse files Browse the repository at this point in the history
  • Loading branch information
CamielBouchier committed Jul 28, 2023
1 parent 817f8d9 commit 540875c
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Release_1_7_2
=============

* Support for ESR115
* Implemented https://github.com/CamielBouchier/cb_thunderlink/issues/59
* Implemented https://github.com/CamielBouchier/cb_thunderlink/issues/58

Release_1_7_1
=============

Expand Down
27 changes: 19 additions & 8 deletions mail_extension/cb_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ var cb_api = class extends ExtensionCommon.ExtensionAPI {
getAPI(context) {
return {
cb_api: {
cb_show_message_from_api_id(api_id, open_mode) {
console.log("cb_show_message_from_api_id", api_id, open_mode)
cb_show_message_from_api_id(tb_version, api_id, open_mode) {
console.log("cb_show_message_from_api_id", tb_version, api_id, open_mode)
// See : https://thunderbird-webextensions.readthedocs.io/en/latest/how-to/experiments.html
// #using-folder-and-message-types
let the_message = context.extension.messageManager.get(api_id)
Expand All @@ -65,15 +65,21 @@ var cb_api = class extends ExtensionCommon.ExtensionAPI {
let tabmail = win.document.getElementById("tabmail")
tabmail.switchToTab(0) //will always be the mail tab
win.focus()
win.gFolderTreeView.selectFolder(the_message.folder)
win.gFolderDisplay.selectMessage(the_message)
if (tb_version <= 102) {
win.gFolderTreeView.selectFolder(the_message.folder)
win.gFolderDisplay.selectMessage(the_message)
} else {
win.gTabmail.tabInfo[0].folder = the_message.folder
win.gTabmail.currentAbout3Pane.selectMessage(the_message)
}
} else {
MailUtils.displayMessage(the_message)
}
}
},
cb_show_message_from_msg_id(msg_id, open_mode, prefer_folders, avoid_folders) {
console.log("cb_show_message_from_msg_id", msg_id, open_mode, prefer_folders, avoid_folders)
cb_show_message_from_msg_id(tb_version, msg_id, open_mode, prefer_folders, avoid_folders) {
console.log("cb_show_message_from_msg_id",
tb_version, msg_id, open_mode, prefer_folders, avoid_folders)
let query = Gloda.newQuery(CB_NOUN_MESSAGE)
query.headerMessageID(msg_id)
query.getCollection({
Expand Down Expand Up @@ -127,8 +133,13 @@ var cb_api = class extends ExtensionCommon.ExtensionAPI {
let tabmail = win.document.getElementById("tabmail")
tabmail.switchToTab(0) //will always be the mail tab
win.focus()
win.gFolderTreeView.selectFolder(the_message.folder)
win.gFolderDisplay.selectMessage(the_message)
if (tb_version <= 102) {
win.gFolderTreeView.selectFolder(the_message.folder)
win.gFolderDisplay.selectMessage(the_message)
} else {
win.gTabmail.tabInfo[0].folder = the_message.folder
win.gTabmail.currentAbout3Pane.selectMessage(the_message)
}
} else {
MailUtils.displayMessage(the_message)
}
Expand Down
10 changes: 10 additions & 0 deletions mail_extension/cb_api_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"async": true,
"parameters":
[
{
"name": "tb_version",
"type": "integer",
"description": "The tb_version."
},
{
"name": "api_id",
"type": "integer",
Expand All @@ -29,6 +34,11 @@
"async": true,
"parameters":
[
{
"name": "tb_version",
"type": "integer",
"description": "The tb_version."
},
{
"name": "msg_id",
"type": "string",
Expand Down
33 changes: 27 additions & 6 deletions mail_extension/cb_background.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ browser.storage.onChanged.addListener(

get_settings() // Actually will kick us of, generating the context menus.

var tb_version

async function get_version() {
let v = await browser.runtime.getBrowserInfo()
tb_version = parseInt(v.version.split('.')[0])
}

get_version()

//
// https://base64.guru/developers/javascript/examples/unicode-strings
//
Expand Down Expand Up @@ -288,17 +297,25 @@ async function create_context_menu() {
contexts : ['message_list'],
title : conf_link.name,
parentId : main_context_id,
id : 'sub_context_menu_' + i,
onclick : on_context_menu
id : 'sub_context_menu_' + i
});

// add sub menu entry to the selection menu
browser.menus.create({
contexts : ['selection', 'tab', 'page'],
title : conf_link.name,
parentId : selection_context_id,
onclick : (info, tab) => on_context_menu_selection(i, info, tab),
id : 'other_menu_'+ i
});

browser.menus.onClicked.addListener((info, tab) => {
if (info.menuItemId.startsWith('sub_context_menu_')) {
on_context_menu(info)
}
if (info.menuItemId.startsWith('other_menu_')) {
on_context_menu_selection(info, tab)
}
})
}
}

Expand All @@ -316,7 +333,8 @@ async function on_context_menu(e) {
//
// Handle menu entries from the right click menu in a (message) tab
//
async function on_context_menu_selection(idx, info, tab) {
async function on_context_menu_selection(info, tab) {
let idx = info.menuItemId.replace('other_menu_', '')
let message = await messenger.messageDisplay.getDisplayedMessage(tab.id);

if (!message) {
Expand Down Expand Up @@ -402,12 +420,15 @@ async function handle_incoming_link(incoming_link) {
console.error("Investigate me. the_message == null. ml:",ml)
return
}
messenger.cb_api.cb_show_message_from_api_id(the_message.id, open_mode)
messenger.cb_api.cb_show_message_from_api_id(tb_version,
the_message.id,
open_mode)
}

if (link_type == 'thunderlink') {
msg_id = link.replace('messageid=', '')
messenger.cb_api.cb_show_message_from_msg_id(msg_id,
messenger.cb_api.cb_show_message_from_msg_id(tb_version,
msg_id,
open_mode,
settings.prefer_folders,
settings.avoid_folders)
Expand Down
Binary file removed mail_extension/cb_thunderlink.xpi.tmp
Binary file not shown.
2 changes: 1 addition & 1 deletion mail_extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"version": "1.7.1",
"version": "1.7.2",
"name": "cb_thunderlink",
"description": "cb_thunderlink is a thunderlink replacement.",
"author": "camiel@bouchier.be",
Expand Down

0 comments on commit 540875c

Please sign in to comment.