thunderbirdthunderbird-addonlightningthunderbird-lightning

trying to access Thunderbird-tabmail does not work


I want to open a new tab with a gloda conversation from inside calendar code.

I receive an error from error console: window not defined (or document not defined), depending on which of the two I use to Access tabmail:

        let tabmail = window.document.getElementById("tabmail");
        let tabmail = document.getElementById("tabmail");

The code works fine if the js file is included in an overlay xul-file.

But I want to use it outside of xul in my code. Somewhere in my calendar code (in my 'addevent'), the same code throws the error. This code is originally called from a rightclick on an email, but several layers deep into calendar code.

In MDN, I read that window is global? So what do I Need to do to add an tab? This part works if tabmail is properly referenced:

      tabmail.openTab("glodaList", {
      collection: queryCollection,
      message: aCollection.items[0],
      title: tabTitle,
      background: false
    });

So how do I get a reference for tabmail?

Any help is appreciated.


Solution

  • after trying and looking through code for really some time before posting, it took only ca. 20 minutes to accidentally find the solution after submitting the question..

    While browsing mailutils on mxr for something else, I found the solution in some function:

        mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
        if (mail3PaneWindow)  var tabmail = mail3PaneWindow.document.getElementById("tabmail");