RealRaven2000 / FiltaQuilla

Adds many new mail filter actions to Thunderbird
http://quickfilters.quickfolders.org/filtaquilla.html
GNU General Public License v3.0
88 stars 17 forks source link

"Play Sound" - Uncaught TypeError: that.window is null #258

Open w4hnsinn opened 7 months ago

w4hnsinn commented 7 months ago

I've been trying to get a sound, any sound, to play when certain emails are caught by a message filter, but to no avail.

I then found out how to open the error console thing and found the following error was being triggered whenever a sound was supposed to be played:

Uncaught TypeError: that.window is null See: image

Note, I am using ThunderbirdPortable, currently v115.9.0 (32-bit), this may well cause interference sometimes, I found in the past, but I'm not sure.

Please let me know if there's something else that can be done besides using the non-portable version of TB.. thanks! <3

RealRaven2000 commented 7 months ago

I transferred this to FiltaQuilla, because the functionality comes from there.

RealRaven2000 commented 7 months ago

Uncaught TypeError: that.window is null

This is initialized when FIltaQuilla starts, and should have a reference to the main window:

    var { ToneQuillaPlay } = ChromeUtils.import("resource://filtaquilla/ToneQuillaPlay.jsm");
    try {
      await ToneQuillaPlay.init();
      ToneQuillaPlay.window = window;
    } catch (ex) {
      FiltaQuilla.Util.logException("ToneQuillaPlay.init failed.", ex);
    }

in the jsm module for the sound player the variable that is set to the object itself:

// shorthand notation for the current module
var that = ToneQuillaPlay;
that.name = "ToneQuillaPlay";

Do you get a message "ToneQuillaPlay.init failed" when you start Thunderbird?

RealRaven2000 commented 7 months ago

I put some code to reinitialise the window when the sound plays, can you test this version please?

In the function that plays the sound, I also added some console output which (only in that case) also displays details on the window and the that variable (which can be clicked on for deeper trouble shooting):

    if (!that.window) { // [issue 258]
      console.log("ToneQuillaPlay.play() - window instance not initialized!;");
      that.window = Services.wm.getMostRecentWindow("mail:3pane");
      console.log("initialized 'that.window' with Servies", {window: that.window, that: that});
    }

filtaquilla-4.1pre2.zip

you will see something like this (ignore the yellow lines they are caused by me debugging it to force the error)

image

to get additional console output, also enable the "debug mode" switch on the FiltaQuilla (About filtaquialla/help) settings page:

image


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

w4hnsinn commented 7 months ago
  1. I hadn't actually checked the error console for any errors at TB startup, and as it turns out, there are two identical ones relating to FQ:

NotFoundError: Could not stat file(F:\Thunderbird Portable\Data\profile\extensions\filtaquilla\applause.ogg) because it does not exist 2 FilterListDialog.js:488:10

And looking at the directory in question, it's not just a missing file, there is no \filtaquilla\ folder at all. So it is not generated when I install, nor is it generated later. I have checked this is true for both the current release version available through addons.thunderbird.net (i.e. filtaquilla-4.0-tb.xpi) as well as for this test version (filtaquilla-4.1pre2.zip) you've provided here. In both cases I installed "from file". I'm assuming this is to do with the "portable" mod of TB.

2. However, the test version does play back sound correctly when triggered from a message filter:

FiltaQuilla 13:19:9.286 [603542 ms]
ToneQuillaPlay.queueToPlay F:\mailboxnotify.wav filtaquilla-util.js:222:13 FiltaQuilla (toneQuillaPlay module) _queueToPlay(F:\mailboxnotify.wav) FiltaQuilla (toneQuillaPlay module) queueing sound, status = 0 FiltaQuilla (toneQuillaPlay module) starting next sound... FiltaQuilla (toneQuillaPlay module) nextSound() FiltaQuilla (toneQuillaPlay module) play() ... FiltaQuilla (toneQuillaPlay module) determined mimeType = audio/wav FiltaQuilla (toneQuillaPlay module) nextSound() FiltaQuilla (toneQuillaPlay module) _clearIgnore()

RealRaven2000 commented 4 months ago

Maybe there is a utility function that unpacks an archive with sounds which may fail on linux... I didn't get a chance to test this maybe I will after 4.1 was published on 16/07/2024