RealRaven2000 / QuickFolders

Thunderbird Add-on: QuickFolders
http://quickfolders.org/
Other
48 stars 9 forks source link

Advanced Search Settings unchecking more than one Accounts fails to save. #464

Closed w-ponds closed 2 months ago

w-ponds commented 3 months ago

This is minor and has to do with the quickMove Advanced Settings. When I unselected the box for "Only show results from current mail account" and then unselected the mail accounts that I didn't want to see results from, after I hit "OK" and tried to sort a message it would not find the folder I typed. I went back and found that all boxes for all accounts were checked which meant they were all excluded from the search. I then unchecked the ones that I did not want to exclude and hit "OK". When I went back to verify settings it had only unchecked one item. So, it seems that all boxes are checked by default once the "Only show results..." box is unchecked. And it seems that you can only uncheck one box at a time and have to hit "OK" after each one. If you uncheck several boxes then only the last box unchecked will stick after hitting "OK". After unchecking and hitting "OK" a few times I was finally able to make all of my selections.

RealRaven2000 commented 3 months ago

Sounds painful. Let me check...

by the way [x] "Only show results from current mail account" should be totally independent from the excluded accounts. It just means that it will only give you results for the account of which you are currently viewing the "current folder". AFAIK the account exclusion list is on top of that setting.

Related Stuff

Also I did one fix with "Only show results from current mail account" that made it not work when triggered from a conversation view - see #451

RealRaven2000 commented 3 months ago

Just testing, first observation: I am able to toggle the "only show results" option without affecting the servers in the exclusion list:

image

however, unchecking the accounts seems to only register one account at a time. My guess is that it is an async operation that isn't finished / completed after closing advanced settings. Or maybe there is a loop that exits (with error) after unchecking the first account. Need to debug.

RealRaven2000 commented 3 months ago

Only the last unchecked box is saved. No errors are registered in error console.... very strange :)

w-ponds commented 3 months ago

Just testing, first observation: I am able to toggle the "only show results" option without affecting the servers in the exclusion list:

image

however, unchecking the accounts seems to only register one account at a time. My guess is that it is an async operation that isn't finished / completed after closing advanced settings. Or maybe there is a loop that exits (with error) after unchecking the first account. Need to debug.

You are correct, I verified this on my end as well. I must have been mistaken when I thought I first observed this.

RealRaven2000 commented 3 months ago

I think I found out why, I was using a global variable QuickFolders.quickMove.Settings.excludedIds which is a copy of the legacy preferences setting extensions.quickfolders.quickMove.premium.excludedAccounts which is json list of servers.

On the click event I update the global list (after removing the checked item) and also save it in Prefs:

image

However the "global" variable in the context of the dialog event handler is not the same as the one in the scope of the script quickmove-settings-dlg.js (not quite sure why at the moment). The main problem here is the legacy approach which loads certain parts of the script globally within a window context (so the global variable QuickFolders which I use as a namespace can have a separate instance in each window, which makes using its "state" a dangerous thing) - the big advantage of web extensions is that they can use the background script for such variables; in legacy world we need to reload the context from storage for each window or access the state from the global instance via the main window (it's complicated).

Anyway, the variable

QuickFolders.quickMove.Settings

is instantiated within theqmSettings singleton, and not updated in the event handler:

  var qmSettings = {
    load: function () {
      const settings = QuickFolders.quickMove.Settings
      // add accounts:
      let myAccounts = util.Accounts,
          accountsbox = document.getElementById('currentFolderCustomize'),
...

I will try and fix this by always using the list from the main window for now.

quickFix version below:

QuickFolders-mx-6.5pre27.zip


To test the version above, download the zip file, drag the file into Thunderbird Add-ons Manager, do not extract contents or if won't install.Please don't close the issue, I will do so myself once the fix goes into production (released in next version)/

RealRaven2000 commented 2 months ago

Fixed in 6.5.1 - Published 16/04/2024