MozillaZine

Display total number of threads in folder pane?

User Help for Mozilla Thunderbird
kswartz
 
Posts: 65
Joined: August 18th, 2004, 4:54 pm

Post Posted June 12th, 2018, 10:27 am

Does anyone know of an addon that will add an option to display the number of total threads per folder in the folder pane, instead of the number of messages? (I would also settle for something that displays the thread count in a bar of the message pane.)

Right now, the only way I can find this information is to collapse all threads in a folder, and then select them all. I'm hoping for something a bit more static than that.

Thanks,
Keith
- Keith
Enterprise Architect

tanstaafl
Moderator

User avatar
 
Posts: 43992
Joined: July 30th, 2003, 5:06 pm

Post Posted June 12th, 2018, 11:20 am

Nope. Though it appears that the ThreadVis add-on lets you "Jump back and forth between messages in a thread, regardless of folder location. Don't be forced to keep all messages in a single folder to display the thread hierarchy, sort messages any way you like and still make sense of the context the mails were sent in." I don't know how practical that is (since it seems you do that using colored dots in a graph in the header of the message you are reading), but it makes me wonder if you might want to dedicate a folder to contain just the latest message in each thread, and use message filters to file the preceding messages elsewhere. That way that folders message count would be the count of the number of active conversations/threads you have. If you did that you might use the inbox only to store relatively new messages that are not in a thread.

https://addons.mozilla.org/en-US/thunde ... is/?src=ss
https://threadvis.github.io

Why do you want to do this? Sometimes knowing that helps somebody suggest a different way to solve the problem.

kswartz
 
Posts: 65
Joined: August 18th, 2004, 4:54 pm

Post Posted June 13th, 2018, 12:52 am

The latter solution doesn't work -- we have much too much activity, and filing/refiling the latest would be too time consuming.

The requirement has to do with metrics in our group. We measure workload (with measurements taken at least every day, sometimes 2x a day) with a number of variables, one of which is the size of our active "queue" (Inbox). We used to measure by number of messages, but found this was unfairly skewing the metrics by over-weighing conversations that were highly active, or had a longer history that needed to tracked. (For instance, lots of older replies with attachments that needed to be preserved). So now we measure by number of conversations/threads.

The only way to get that now is to select all and look at the total. I figure if TB can report that total, there must be a way to get it without having to actively select, and display it somewhere.

I actually think even having it in the status bar would be sufficient (although it may not work with TB 60+). It already lists Unread and Total there -- and the Lightning extension adds Invitations there. So the capability is definitely there. (Alas, these days, I lack the free time to build something myself.)

Thanks for the quick reply.
- Keith
Enterprise Architect

tanstaafl
Moderator

User avatar
 
Posts: 43992
Joined: July 30th, 2003, 5:06 pm

Post Posted June 13th, 2018, 7:28 am

I suggest you try contacting the author of one of the thread-centric add-ons and see if you can interest them in adding your feature. I'd normally recommend Paolo "Kaosmos" (author of ImportExportTools etc.) as he has a history of adding features (or even creating a new add-on in some cases) upon request but he has put his add-on development on hold until the direction of Thunderbird add-ons clears up. If you already use the Thunderbird Conversations add-on perhaps contact it's author?

Another solution might be to write a script file that counts the number of threads in a folder, displaying the count when it ends. The advantage of that is you might be able to schedule it running using Windows Task Scheduler and also have it submit the count somewhere, totally getting the user out of the loop.

http://kb.mozillazine.org/Stop_threading_by_subject
https://www.commandlinefu.com/commands/ ... -mbox-file
https://lifehacker.com/179514/geek-to-l ... win-part-i
https://stackoverflow.com/questions/123 ... es-in-unix

Thunderbird stores the messages for each folder in a different mbox file. Its a flat plain text file named after the mail folder, with no file extension. i.e. "inbox." is the mbox file for the inbox folder. Ignore "inbox.msf" (a cache of the folder listing).

If you assume each thread uses a unique References: header you could create a script that counts the number of unique Reference headers in the mbox file. That would not be as convenient as displaying the thread count in the status bar, but would automate the process. There are lots of scripts in python, perl and javascript to parse mbox files that you can find as a starting point. Or you could use command line utilities such as this example of how to sort and count subjects of emails stuck in Exim queue. Cygwin probably has the text processing utilities that you'd need.

grep -R Subject /var/spool/exim/input/ | sed s/^.*Subject:\ // | sort | uniq -c | sort -n > ~/email_sort.$(date +%m.%d.%y).txt

morat
 
Posts: 2682
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 13th, 2018, 9:21 am

Do you want an alert dialog to show the total number of threads for the selected folder using the Keyconfig extension?

Code: Select all
var totalThreads = 0;
var threadTree = document.getElementById("threadTree");
for (var i = 0; i < threadTree.treeBoxObject.view.rowCount; i++) {
  if (threadTree.treeBoxObject.view.getLevel(i) === 0) {
    totalThreads = totalThreads + 1;
  }
}
var folder = gFolderDisplay.displayedFolder;
var title = "Folder Stats";
var description = "Unread: " + folder.getNumUnread(false) +
  ", Total: " + folder.getTotalMessages(false) +
  ", Threads: " + totalThreads;
Services.prompt.alert(window, title, description);

Keyconfig
http://addons.mozilla.org/thunderbird/addon/602486

P.S.

Here is the code to select all threads.

Code: Select all
goDoCommand("cmd_selectAll");
goDoCommand("cmd_collapseAllThreads");
goDoCommand("cmd_expandAllThreads");

tanstaafl
Moderator

User avatar
 
Posts: 43992
Joined: July 30th, 2003, 5:06 pm

Post Posted June 13th, 2018, 12:29 pm

I'm embarrassed I didn't think of that possibility :)

kswartz
 
Posts: 65
Joined: August 18th, 2004, 4:54 pm

Post Posted June 14th, 2018, 12:18 am

Interesting - I like the keyconfig alert (I already use keyconfig, too). I think if I can change from an alert to having it display that information in the status bar, next to the unread/total numbers, I'd have something very usable and unintrusive. (And then, in theory, couldn't I run that script in a loop with a timer?)

-Keith
- Keith
Enterprise Architect

morat
 
Posts: 2682
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 14th, 2018, 1:11 am

It would be too much trouble to show the total threads for all folders in the folder pane because there isn't a method for total threads like there is for total messages. It is possible to show the total threads for the selected folder in the status bar with a legacy extension. I guess I would hack the UpdateStatusMessageCounts function.

nsIMsgFolder getTotalMessages
http://developer.mozilla.org/en-US/docs ... ages.28.29

UpdateStatusMessageCounts
http://dxr.mozilla.org/comm-esr52/searc ... sageCounts

@tanstaafl

Luckily, Jonathan is still supporting the Keyconfig extension.

morat
 
Posts: 2682
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 14th, 2018, 9:43 am

*** for advanced users only ***

Try this:

Code: Select all
/* Thunderbird userChrome.js */

(function () {

if (location == "chrome://messenger/content/messenger.xul") {

  setTimeout(function () {

    UpdateStatusMessageCounts = function (folder) {
      var unreadElement = document.getElementById("unreadMessageCount");
      var totalElement = document.getElementById("totalMessageCount");
      if (folder && !folder.isServer && unreadElement && totalElement) {
        var numSelected = gFolderDisplay.selectedCount;
        var bundle = document.getElementById("bundle_messenger");
        var numUnread = (numSelected > 1) ?
          bundle.getFormattedString("selectedMsgStatus", [numSelected]) :
          bundle.getFormattedString("unreadMsgStatus", [folder.getNumUnread(false)]);
        var numTotal = bundle.getFormattedString("totalMsgStatus", [folder.getTotalMessages(false)]);
        var totalThreads = 0;
        var threadTree = document.getElementById("threadTree");
        for (var i = 0; i < threadTree.treeBoxObject.view.rowCount; i++) {
          if (threadTree.treeBoxObject.view.getLevel(i) === 0) {
            totalThreads = totalThreads + 1;
          }
        }
        unreadElement.setAttribute("label", numUnread);
        totalElement.setAttribute("label", numTotal + " or " + totalThreads);
        unreadElement.hidden = false;
        totalElement.hidden = false;
      }
    }

  }, 1000);

}

if (location == "chrome://messenger/content/messageWindow.xul") {}
if (location == "chrome://messenger/content/messengercompose/messengercompose.xul") {}

})();

Instructions:

* install userChromeJS extension
* close email client
* create or edit the userChrome.js file in the chrome folder
* open email client with the -purgecaches command line option

i.e.

thunderbird.exe -purgecaches
ThunderbirdPortable.exe -purgecaches

You have to purge the javascript caches only after creating or editing the userChrome.js file.

http://userchromejs.mozdev.org/
http://userchromejs.mozdev.org/faq.html

userChromeJS 2.0 is signed by Mozilla.

Extension Signing
http://wiki.mozilla.org/Add-ons/Extension_Signing

If I try to install an unsigned extension like userChromeJS 1.7 in Firefox ESR 52, then I get the following error message.

This add-on could not be installed because it has not been verified.

Thunderbird does not require extensions to be signed, but I would trust signed extensions that work in Firefox.

MD5, SHA1, SHA256 for userchromejs-2.0-sm+tb+fx.xpi file:

371759c10b3553e8b04a11c5e43a9a3a
3cccc21f3c5798c4f663ae1d754143ad0a446b8a
c72bdf4c4d815ee29bacaab54368ffc242d0e970f8ca9ff21f2d5901f1d891ac

Also, I believe userChromeJS 2.0 has a bug in Thunderbird 57 and above.

More info: viewtopic.php?p=14783122#p14783122

userChromeJS 2.0 (signed)
Thunderbird 52.8.0
Windows 7 SP1 32-bit

kswartz
 
Posts: 65
Joined: August 18th, 2004, 4:54 pm

Post Posted June 14th, 2018, 10:47 am

This community is awesome. Thank you SO much for these suggestions. Morat -- I'm going to give your solution a shot, right after I make a few backups. :)

Now I have to keep my fingers crossed that this all won't go to crap if TB drops legacy extensions in 60+. (I've already started moving over to Basilisk in Firefox because of it. Too many things I've built and become too attached to over the years, and no time/motivation to rewrite them.)
- Keith
Enterprise Architect

kswartz
 
Posts: 65
Joined: August 18th, 2004, 4:54 pm

Post Posted June 14th, 2018, 11:33 am

Just a followup to note that morat's suggestion works perfectly. And it's FAST, even in a folder with over 28000 messages. Maybe someday I'll see if I can tackle putting this into the folder pane, just for kicks, but this meets all my requirements today.

Thank you all!
- Keith
Enterprise Architect

morat
 
Posts: 2682
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 14th, 2018, 4:30 pm

You're welcome.

Return to Thunderbird Support


Who is online

Users browsing this forum: Google [Bot] and 5 guests