Skip to content

Commit

Permalink
v3.1.4
Browse files Browse the repository at this point in the history
(2020-12-20)

! when "force" is enabled double click on a message would open a wrong message in a new tab
  • Loading branch information
vanowm committed Dec 20, 2020
1 parent d9069c3 commit 547b042
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
50 changes: 37 additions & 13 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,30 @@ function main(window)
listener =
{
timer: null,
last: 0,
onMessagesLoaded: function listener_onMessagesLoaded(aAll)
{
listener.selectMessageDelayed.apply(this, arguments);
},

onMakeActive: function listener_onMakeActive()
{
listener.selectMessageDelayed.apply(this, arguments);
},

calls: [],
selectMessageDelayed: function listener_selectMessageDelayed()
{
if (this.timer)
this.timer.cancel();

let that = this,
args = arguments;

this.calls[this.calls.length] = arguments[arguments.length-1];
//the timer needed to allow time to restore previous selection if any
this.timer = setTimeout(function(){listener.selectMessage.apply(that, args)}, 0);
},

selectMessage: function listener_selectMessage(obj)
{
let calls = Object.assign([], this.calls);
this.calls = [];
if (!prefs.sel)
return;

let isTextbox = this.isTextbox(window.document.activeElement);

if (obj.view.dbView && (!obj.view.dbView.numSelected || (obj.view.dbView.numSelected && !isTextbox && prefs.selForce)))
if (obj.view.dbView && (!obj.view.dbView.numSelected || (obj.view.dbView.numSelected && !isTextbox && prefs.selForce && calls.indexOf("onDisplayingFolder") != -1)))
{

let msgDefault = Ci.nsMsgNavigationType.firstMessage,
Expand Down Expand Up @@ -130,7 +124,37 @@ function main(window)
onTabClosing: function tabMan_onTabClosing(){},
onTabSwitched: function tabMan_onTabSwitched(tab){},
};

!function()
{
let listenerEvents = [
// "onActiveCreatedView",
// "onActiveMessagesLoaded",
// "onCreatedView",
// "onDestroyingView",
"onDisplayingFolder",
// "onFolderLoading",
// "onLeavingFolder",
// "onLoadingFolder",
"onMakeActive",
// "onMessageCountsChanged",
// "onMessagesLoaded",
// "onMessagesRemovalFailed",
// "onMessagesRemoved",
// "onSearching",
// "onSortChanged",
];
for (let i = 0; i < listenerEvents.length; i++)
{
let name = listenerEvents[i];
this[name] = function()
{
let args = Array.prototype.slice.call(arguments);
args[args.length] = name;
this.selectMessageDelayed.apply(this, args);
}
}
return true;
}.bind(listener)(),
window.FolderDisplayListenerManager.registerListener(listener);
listen(window, window, "unload", unload(function()
{
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "Auto Select Latest Message",
"author": "V@no",
"description": "Automatically select and display latest message on startup or when switching folder for the first time",
"version": "3.1.3",
"version": "3.1.4",
"experiment_apis": {
"BootstrapLoader": {
"schema": "api/BootstrapLoader/schema.json",
Expand Down

0 comments on commit 547b042

Please sign in to comment.