RealRaven2000 / quickFilters

Thunderbird Add-on: quickFilters
http://quickfilters.quickfolders.org/
Other
46 stars 11 forks source link

Feature request: disable assistant when dragging mail _from_ special folders #164

Closed molitar closed 1 year ago

molitar commented 1 year ago

So I updated my quickFilters addon to latest version and when I tried to create a new exclusion I realized the search box does not allow anything to be typed in and pressing the + button creates the default but does not allow renaming so unable to create a new folder exclusion. I have attached an image showing this.

quickFilters Exclusion

RealRaven2000 commented 1 year ago

Yes it is not designed to created your own exclusions - for this we would need to know the internal flag not just a word like "drafts". Can you please explain exactly what you are trying to do?

I assume the assistant pops up when it is not expected - please write exactly the steps you do that create the assistant for you.

Personally I haven't been able to invoke the assistant by drafting emails. Even if I close composer and reopen the draft later. I would not expect the assistant related to drafts, and I don;t think there would be any valid use case where this would be desirable. So I would rather disable this completely, once you tell me how to reproduce the problem.

molitar commented 1 year ago

Emails that need attention soon I drop into my drafts folder as they remain marked unread so I do not forget.. when I get the chance I go take care of them. These could be bills or urgent emails. So when I finish I drop the email back into the correct folder and it is at this point that it gets triggered as a move.

All indications look like it is designed to add your own exclusion folders.

RealRaven2000 commented 1 year ago

Emails that need attention soon I drop into my drafts folder as they remain marked unread so I do not forget.. when I get the chance I go take care of them. These could be bills or urgent emails. So when I finish I drop the email back into the correct folder and it is at this point that it gets triggered as a move.

ok, so you are using the drafts folder (which is supposed to only have your own emails) in a slightly different way than intended. No problem, I can code an exception for that.

All indications look like it is designed to add your own exclusion folders.

Unfortunately not, it's actually quite complicated. For instance, for trash I had to Monkey patch an internal function (DefaultController.doCommand()) of Thunderbird in order to make it work when the user hits the [DEL] key. The universal method (Folder Listener) introduced in 5.7.1 had to be rolled back because it lead to performance problems and crashes on some systems. There is a lot of code involved for each individual case. I generally exclude these special folders from the assistant:

  checkAssistantExclusion: function(targetFolder) {
    // Avoid triggering assistant
    const FLG = quickFilters.Util.FolderFlags,
          isArchiveExcluded = quickFilters.Preferences.getBoolPref("assistant.exclude.archive");
    let excluded = FLG.Queue | FLG.Templates  | FLG.SentMail  | FLG.Drafts  | FLG.Newsgroup;
    const isMoveDebug = quickFilters.Preferences.isDebugOption("msgMove");
    if (quickFilters.Preferences.getBoolPref("assistant.exclude.trash")) {
      ...

as you can see in the code snippet above the "Drafts" flags should already be excluded; I will test what's wrong with it. Note that a folder needs to be configured as "Drafts" in Thunderbird to have the flag; merely naming it "Drafts" will not make it a drafts folder.

image

RealRaven2000 commented 1 year ago

I tested this with an IMAP account:

image

Neither of them triggered the assistant. What am I doing wrong?

molitar commented 1 year ago

I dragged mine into the drafts just below the inbox. When I move it back out it triggers. Also I am using POP email.

RealRaven2000 commented 1 year ago

I dragged mine into the drafts just below the inbox. When I move it back out it triggers. Also I am using POP email.

When I move it back out it triggers

That's the one. Ok I will find a solution for you. I never tested that, because normally you edit a draft and then send it (and Thunderbird deletes it). Must say that is a very special use case (never heard of that of any of the other 17,000 users). But then there is no harm in suppressing it, because I cannot imagine that a filter would ever wanna do this automatically.

Note that the existing restrictions all apply to the target Folder (not the source, like in your case).

RealRaven2000 commented 1 year ago

I have made some modification as a test, which will omit the assistant when you move mail from the folders Drafts, Templates, Trash or Queue. These are kind of the "odd folders" I can think of that you normally wouldn't move mail from manually (most of them automated). You probably would also not want to create an automatic rule for rescuing mail from the Trash (although you might want to do this in a rescue operation; so I am not super sure about that one). So there is 2 functions now checkAssistantTargetExclusion()- which I just renamed the checkAssistantExclusion() from, because it only handles targets.

And there is a new function checkAssistantSourceExclusion() which is currently hard coded. I might add some configurability (and UI) later - should the need arise:

  checkAssistantSourceExclusion: function(sourceFolder) {
    const FLG = quickFilters.Util.FolderFlags;
    if (!sourceFolder) return false;

    let excluded = FLG.Queue | FLG.Templates | FLG.Drafts | FLG.Trash;
    if (excluded & sourceFolder.flags) {
      return true;
    }
    return false;
  },

Here is a trial version: quickFilters-wx-5.8.2pre1.zip

caveat -- I tested it with my Imap mailbox and when I dragged mail from drafts to the gmail inbox it didn't trigger the assistant (as expected). However it did show this weird message from Thunderbird that I never have seen before: image

Not sure what it means, because I have never before moved mail from the draft folders (only deleted) as there was no reason to do so. Drafts are just unfinished thing I have started to write, in my mind there is no need to move that stuff anywhere. That's why not triggering the assistant is also no loss at all to me (and I believe for my users).

To install the prerelease above, as usual, download the zip file and then drag that file into Thunderbird Add-ons Manager. Looking forward to your comments. If you think about the selection above, which other source folder types should the assistant ignore?

molitar commented 1 year ago

OK tested and it works great one that we may also want to add is sent folder. Sometimes you send an email that is important for work or business and you want to make sure you keep a copy so you copy it back to a folder. The other folders you added all tested fine also. Thanks for the update.

RealRaven2000 commented 1 year ago

OK tested and it works great one that we may also want to add is sent folder. Sometimes you send an email that is important for work or business and you want to make sure you keep a copy so you copy it back to a folder. The other folders you added all tested fine also. Thanks for the update.

No worries; however - I don't think excluding Sent (by default) is a good idea as people might actually include that into their workflow of creating filters using the "Recipient" template. Personally I use "Copy Sent to Current" so I never, ever have to visit the Sent folder - it's a bit of a waste of time when you can have your replies right in the thread with the original messages where they belong.

I will probably rename the configuration button "Assistant should ignore these folder types..." to "Exclude target folders..." maybe with a ? panel and explanation popup.

molitar commented 1 year ago

yeah that would make more sense exclude and we can exclude any of them folders we want excluded or not.

RealRaven2000 commented 1 year ago

Implemented in v5.9 - Published 28/03/2023