Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tb115 - account template not loaded when changing From address #256

Closed
RealRaven2000 opened this issue Sep 8, 2023 · 5 comments
Closed
Assignees
Labels
bug ESR 115 Changes for Thunderbird SuperNova UI

Comments

@RealRaven2000
Copy link
Owner

When selecting a different identity, the new one isn't selected in SmartTemplates 4.1. instead we see the following error log:

Uncaught (in promise) TypeError: this.smartTemplate is undefined
    loadIdentity chrome://smarttemplate4/content/smartTemplate-main.js:741
    LoadIdentity chrome://messenger/content/messengercompose/MsgComposeCommands.js:9533
    oncommand chrome://messenger/content/messengercompose/messengercompose.xhtml:1
smartTemplate-main.js:741:11
@RealRaven2000 RealRaven2000 added bug ESR 115 Changes for Thunderbird SuperNova UI labels Sep 8, 2023
@RealRaven2000 RealRaven2000 self-assigned this Sep 8, 2023
@RealRaven2000
Copy link
Owner Author

It appears that the new event handler "compose-from-changed" calls SmartTemplate4.loadIdentity() with the wrong context. "this" evaluates to ChromeWindow chrome://messenger/content/messengercompose/messengercompose.xhtml and not to the SmartTemplate4 instance of the script. This can be changed by binding a different context in the event listener.

  // old code
  window.addEventListener("compose-from-changed", SmartTemplate4.loadIdentity);
  // new code:
  window.addEventListener("compose-from-changed", SmartTemplate4.loadIdentity.bind(SmartTemplate4));

After fixing that, on top of that I am still having problems when detecting the change - because changing the identity during LoadIdentity() in core sets the gMsgCompose.bodyModified flag:

image

this is a problem because I do not allow changing the mail text if it was already modified (in my mind, this flag is / should be reserved for the user having edited the email)

@RealRaven2000
Copy link
Owner Author

RealRaven2000 commented Sep 8, 2023

Ok, here is the bigger picture:

image

the problem is exactly when I would need the bodyModified flag to tell me the truth it pretends that the email was edited. I need to follow the triggering of this and load the identity template but need to know that this event was caused by Thunderbird's LoadIdentity function and nothing else. I will search the Core database to see whether it is being triggered from anywhere else.

@RealRaven2000
Copy link
Owner Author

Just playing this through - Thunderbird (I believe falsely) also resets the bodyModified flag in this case after the user has done edits. I don't think it should do this, it should store the previous bodyModfied state and restore it at the end of LoadIdentity(). Ideally it should do that before dispatching the compose-from-changed event

@RealRaven2000
Copy link
Owner Author

Since I cannot determine reliably whether the body was modified when the user changes the identity, I have decided to prompt them:

image

Clicking OK will discard anything that was written by the user since composer started, Cancel will leave the contents of the email unchanged (It may swap the signature out though).

smartTemplate-fx-4.1.1pre10.zip


To install the preview version above, please download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract file contents, as they won't install.

@RealRaven2000 RealRaven2000 changed the title Tb115 - this.smartTemplate is undefined when changing identity Tb115 - account template not loaded when changing From address Sep 21, 2023
@RealRaven2000
Copy link
Owner Author

Implemented in 4.2.1, published 25/09/2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ESR 115 Changes for Thunderbird SuperNova UI
Projects
None yet
Development

No branches or pull requests

1 participant