RealRaven2000 / quickFilters

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

Switching off quickFilters for delete and archive destroys my main use case #155

Closed mathias-muench closed 1 year ago

mathias-muench commented 1 year ago

Unfortunately the change in version 5.7.1 (#142) that switches off quickFilters for delete and archive destroys my main use case. I (mis-)use quickFilters to bulk-delete or bulk-archive messages e.g. from one online purchase or multiple newsletters that have piled up. I use the following sequence for that:

Filter erzeugen -> OK -> Jetzt ausführen -> Löschen

Reverted to 5.7 now and switched off automatic updates, but this is not a real solution obviously. :-(

RealRaven2000 commented 1 year ago

I am working on a solution, the main problem is that we can't use the folder listener (introduced in 5.7) for general filter assistant duty, so I am actually working on a rollback to the previous version (5.6) at least in the parts where the assistant methods are concerned. I already made a bespoke solution for archiving which hooks into the Archive function, but deleting is currently supporting the assistant if you drag or more mail to the waste basket, and not when using the [DEL] key. Astonishingly, there is no global "message Delete" function I could hook into here, I am still looking into a way to do this.

With the folder listener I did support using the [DEL] in a prerelease here - one might say this issue is a duplicate strictly speaking, but that method will likely go away again after rolling back, so bear with me until I can present something new here that you can test.

I have already added a user interface for using delete to trigger assistant:

image

where by default including trash is allowed (exclude = false):

image

RealRaven2000 commented 1 year ago

If you can delete any other way than the DEL key (involving the folder either by dragging to tree or a QuickFolders tab or the "move to folder" context command) then this version may already help you:

quickFilters-wx-5.8pre89.zip

Archiving is fully supported. To install, download the zip file and drag that zip file into Thunderbird Add-ons Manager (do not extract contents). zip = xpi, but github attachments do not allow the later file extension.

RealRaven2000 commented 1 year ago

In older builds of Thunderbird / still in Seamonkey, we have the function MsgDeleteMessage(). Newer build will still go through the global function goDoCommand(), which is a really central function for any global commands within the main window. This then will call the local controller with controller.doCommand():

  // from globalOverlay.js
  try {
    var controller = top.document.commandDispatcher.getControllerForCommand(
      aCommand
    );
    if (controller && controller.isCommandEnabled(aCommand)) {
      controller.doCommand(aCommand);
    }
  } catch (e) {
    Cu.reportError(
      "An error occurred executing the " + aCommand + " command: " + e
    );
  }

So I guess the most universal but specific solution to the problem would be to monkeywrap controller.doCommand() and execute the assistant if it was called with an argument of "cmd_delete". At the moment I do not know when the specific controller is being initialized and whether there is one per mail window / tab or whatever generates this object.

RealRaven2000 commented 1 year ago

Some boilerplate code here:

// check whether command was cmd_delete or button_delete
// then check whether it is actually enabled first
function docommandWrapper(cmd) {
  if (cmd=="cmd_delete" || cmd=="button_delete") &&  DefaultController.isCommandEnabled(cmd)) {
    // determine which messages are currently selected
    // then call assistant first. Or alternatively call after original function returns true.
    // original call was gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.deleteMsg);
  }
  originalDoCommand(cmd);
}

note: the lowest level function FolderDisplayWidget.doCommand() calls dbView stuff which is compiled (C++ code) and cannot be touched / modified by an Add-on.

RealRaven2000 commented 1 year ago

Took a little while (maybe 2-3 hours) to write and somewhat test this code, this version should support creating filters through the Delete action (as opposed to dragging email to the Trash folder) and also merging such filters, with the resulting action "Delete Message". Obviously this is better than storing an absolute message URI (and having the action move to folder .../Trash) because you can easily copy the filter to other accounts and will still work (using the account specific Trash folder there).

The assistant will retrieve the correct trash folder based on the flag by using the function sourceFolder.server.rootFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Trash)

(although I do later add the action delete the rest of the logic of building filters still requires there to be a non-empty target folder, so I had to add this bit of logic).

quickFilters-wx-5.8pre101.zip

Deleting Mail (and creating filters from that using assistant) should now be fully supported. To install, download the zip file and drag that zip file into Thunderbird Add-ons Manager (do not extract contents). zip = xpi, but github attachments do not allow the later file extension.

mathias-muench commented 1 year ago

Tried - delete via DEL and dragging to trash both works nice. Archive is ok with dragging (after changing setting for not excluding). With "A" it brings me to "Filter erzeugen", but then the popup just closes without a chance to apply the filter. Definitely not a big problem, main functionality is back again. Many thanks.

RealRaven2000 commented 1 year ago

Tried - delete via DEL and dragging to trash both works nice. Archive is ok with dragging (after changing setting for not excluding). With "A" it brings me to "Filter erzeugen", but then the popup just closes without a chance to apply the filter. Definitely not a big problem, main functionality is back again. Many thanks.

you know that you need FiltaQuilla for archiving and need to enable the archiving action, right? See FQ settings, Filter Actions tab, to enable the non-standard "archive" action:

image

When you go to create the filter after archiving (using filter assistant), do you get as far as editing the filter? You may need these 2 quickFilters options:

image

RealRaven2000 commented 1 year ago

One more question about your workflow (bulk deleting mail + creating filters from that) - did this actually work with 5.6 or earlier versions?

mathias-muench commented 1 year ago

Actually I don't know. I was only using "drag to Trash/Archive" up to some days ago. That it may work with DEL and A I realized only due to this issue. After I knew, the behaviour of 5.7.0 of course was perfect for me.

RealRaven2000 commented 1 year ago

Actually I don't know. I was only using "drag to Trash/Archive" up to some days ago. That it may work with DEL and A I realized only due to this issue. After I knew, the behaviour of 5.7.0 of course was perfect for me.

OK, if you drag to the trash / archive folder explicitely then the filter action will be "move to folder" and not "delete mail" or "archive mail", which not ideal especially if you have annual archives. E.g you would drag an email from 2022 to "archives/2022" and then create a rule for all following mails to go there (even older or newer one). Whereas if you use the "archive mail" command, the filter command will now be "archive mail" and it will apply the correct logic and archive according to the date stamp of the email.

molitar commented 1 year ago

Hello when will we see the assistant will ignore these folders? I want to have deleted folders ignored when I want to restore from deleted folder it will trigger QuickFilters. Also same for Draft I come back to finish it than it gets triggered. So I prefer to have both these folders ignored.

RealRaven2000 commented 1 year ago

I want to have deleted folders ignored when I want to restore from deleted folder it will trigger QuickFilters. Also same for Draft I come back to finish it than it gets triggered.

it's a pity you didn't ask a little earlier - I reseleased 5.8 today. in this version you can only ignore deleting / archiving. when you move an email from the deleted folder back to another (via drag and drop) it might trigger the assistant. hasn't really been complained about.

how do edit a draft? normally you would double click on the draft, then edit and send it off. this should not trigger the assistant in 5.8

by the way the assistant isn't starting automatically by default. normally you would turn on the assistant when you intend to create new filters only.

RealRaven2000 commented 1 year ago

Final Implementation in 5.8.1 on 18/02/2023