Closed pd5rm closed 8 years ago
Very nice! It works for me. I tested it on my Linux machine and had no problems.
One remark. If foldersIncluded
is empty, each notification is blocked. IMHO, empty foldersIncluded
should indicate that filtering is disabled, so no notification should be blocked.
Really, that's great! Can you tell me how to package a xpi? I was copy/pasting the js file over an unzipped xpi.
Yeah, I agree. If foldersIncluded is empty, then all notifications should pass through.
Can you tell me how to package a xpi?
There is jpm tool. To create xpi package, run under the source directory the jpm xpi
command.
Thanks, I used the jpm tool to build and install.
I made the empty setting change you requested.
I'm still not able to get it working right. If I specify "inbox", and send mail to myself I don't see it notify. If I remove the inbox item from the list, it sends the notification.
I figured it was name of the folder not matching, but I couldn't get the console.log to print stuff out in the Thunderbird error console.
The issue was in for-in
loop. It behaves in javascript slightly different from what you might expect. Here is my version of isFolderAllowed:
function isFolderAllowed(folder) {
var sps = require("sdk/simple-prefs").prefs;
var foldersAllowed = sps['foldersAllowedList'];
if (foldersAllowed !== "") {
var foldersAllowedList = foldersAllowed.split(",");
for (var i = 0; i < foldersAllowedList.length; i++) {
if (folder.prettiestName == foldersAllowedList[i].trim())
return true;
}
}
else {
return true;
}
return false;
}
To enable console.log
, follow this instruction.
Looking forward for your next update :-)
Thanks for your help in debugging. I've added some of your style suggestions.
This code seems to work for me. I'll test on my setup for a couple days.
Note. I had to enable the 'app' object at top-level to get logging working. I couldn't find loglevel in TB config to make it output all log level for console.
Cool. Thanks for your contribution :-)
I couldn't find loglevel in TB config to make it output all log level for console.
To make it work without 'app', you have to create in about:config new entry extensions.sdk.console.logLevel
with value all
. In general, using this 'app' interface is not super great idea because it is not supported in Firefox - it only works in TB.
FYI In 601bbd2 commit, I extended filtering functionality. So now, optionally, you can define also name of the account. Example: "My email|Inbox, My folder" will only allow notifications from "Inbox" folder under "My email" account and from any folder with name "My folder".
THIS CODE IS BROKEN.
It seems to crash when I package it into an XPI, and try to load the preferences screen.
Note: this is my first attempt at XPIs, Thunderbird API, and JS. ;-)