RealRaven2000 / QuickFolders

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

"Empty Junk" command intermittently hidden from context menus #406

Closed AdrianChallinorOsiris closed 11 months ago

AdrianChallinorOsiris commented 1 year ago

Since upograding to TB 115.2.3 and QuickFolders 6.2 my "Empty Junk" popup command when in Junk Mail is not working,

RealRaven2000 commented 1 year ago

Works for me. Can you check error console?

RealRaven2000 commented 1 year ago

PS: I am using the command from the navigation toolbar (current folder toolbar) center screen

image

crablouis commented 1 year ago

I hate to pile on, but I'm finding that Empty Junk and Empty Trash are not always appearing on the context menus. I didn't think to associate this with QuickFolders, as the behavior manifests when selecting the respective folder nodes in the Folder Pane.

I don't use the QF Folder Toolbar, so I didn't know an Empty Junk command appears there (frankly, I don't understand that UI context, but if it works for others, great...)

Reading this bug opening narrative makes me suspicious. And sure enough, restarting TBird with the QF extension set to disabled seems to fix it. Gah.

AdrianChallinorOsiris commented 1 year ago

Did a full reboot of Linux, reloaded Thunderbird and its now working.

On 26/09/2023 23:51, RealRaven2000 wrote: Works for me. Can you check error console?

RealRaven2000 commented 1 year ago

Reading this bug opening narrative makes me suspicious. And sure enough, restarting TBird with the QF extension set to disabled seems to fix it. Gah.

this still may be a coincidence. Thunderbird stores special abilities (such as "junk" or "archive") as folder flags (a bitmask that is stored in folder properties) - QuickFolders reads these tags, but never changes them. You can check the flags using this Add-on:

https://addons.thunderbird.net/en-US/thunderbird/addon/folderflags/?src=search

this adds a page to the folder properties panel:

image

if the flags change during the session, then you have faulty profile or found a Thunderbird bug.

crablouis commented 1 year ago

Interesting extension. The previously absent commands appear on restarting TBird. No change in flag setting.

Then, the Empty commands disappear on manipulation of the folder pane objects: Moving cursor selection to a different account; collapsing and expanding account folder trees; switching from Unified to All Folders folder view modes. These actions result in the Empty commands disappearing. The Flag selections don't change.

To be clear, the trash and junk folders always appear. It's the context menu "empty" commands that pop in and out of presence.

TBird restarted in Safe Mode does not have this problem. No Empty commands popping in and out of existence.

Gad, building a new profile and moving my gigabytes of mail into it - scary.

Thanks for the help in any case.

crablouis commented 1 year ago

For what it may be worth, disabling all extensions and restarting, ceases the disappearing command behavior. Then re-enabling QuickFolders sees a renewal of the disappearing context menu command behavior.

RealRaven2000 commented 1 year ago

Are you referring to the popup menu that appears whe you right-click in Folder tree?

image

QuickFolders does not interfere with this one at all. if it's not that one, please clarify with a screenshot, sop I know which menu you are talking about.

AdrianChallinorOsiris commented 1 year ago

No.

I am in the Junk Mail folder, and I click on menu just below the message list.

image

(from https://imgur.com/yNpk5Ps)

RealRaven2000 commented 1 year ago

Ok I have edited your post on Github becuase there is a lot of private information you may not want to share when you reply via email. You are using the QuickFolders "Current folder" panel. But that should read the flags from the folder. I noticed it says "Download add (owl)" on the top, so I guess you are on an Exchange Server? Maybe there is a stability issue here, in that the flags are not translated correctly (or fast enough) from the file interface. You are using Benoex's Add-on to access your email?

I would need to test with an owl account to see what is happening.

I am using my function QuickFolders.Interface.appendMailFolderCommands to create this menu. Here is the relevant code:

if (prefs.getBoolPref("folderMenu.emptyJunk"))
{
  if (folder.flags & util.FolderFlags.MSG_FOLDER_FLAG_JUNK) {
    menuitem = this.createMenuItem_EmptyJunk(doc);
    if (menuitem) {
      MailCommands.appendChild(menuitem);
      if (isRootMenu)
        topShortCuts ++ ;
    }
 }

I made you a special version with additional debug log items: QuickFolders-mx-6.3pre22.zip

download the zip file and drag it into Tb Add-ons manager. make sure to (1) enable debug mode (QF advanced settings). then (2) right-click and activate (3) extensions.quickfolders.debug.popupmenus = true

image

Ctrl+Shift+J opens error console, configure like this: image

Clear the output image

When you go to Junk (from any other folder) you should see something like this: image

you can right-click to copy the complete debug log (please do not screenshot it, that's painful to analyse)

There should be a message reading "Creating Popup Set for Junk", it will list the current flags of the folder.

Eccenux commented 1 year ago

The bug comes from QuickFolders. Not sure why but it removes items from the default context menu. I don't think you should do that at any point.

I've confirmed that removing QuickFolders helps to resolve the issue.

tb_snova_junktrash_new

Still kind of feels like extensions shouldn't be able to remove such items (so seems like something TB should block maybe...). But that is for Mozilla to decide. Report on Mozilla bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1855488

Eccenux commented 1 year ago

Is there a way to disable context menu in QuickFolders so that this doesn't happen? Or to disable some options?

Eccenux commented 1 year ago

The problem only occurs when you open the folder. Steps:

  1. Open TB.
  2. Install QuickFolders
  3. Go into Junk/Spam or Trash (e.g. to see what is inside before empting it).
  4. Right click (for the current folder context menu).
  5. → no Empty Junk / Empty Trash action.

I would assume this happens because quickfolders is doing a copy of the menu without doing a deep clone of it and then removes some items from the copied object (removing them from the builtin context menu)... Just a guess but I've seen this happen for a component framework in JS world.

Workaround: change current folder (to something different then junk/trash), right click junk/trash and the action should be there.

RealRaven2000 commented 1 year ago

The affected menu item is identified as #folderPaneContext-emptyJunk. For styling or labelling reason I am currently using the same id for in own context menu.

let's see if there is a condition where we remove it from somewhere (or make invisible) we shouldn't.

RealRaven2000 commented 1 year ago

There is some code that listens for the folderPane toolbar popup to show and that toggles the visibility of the (alternative) items #context-quickFoldersRemoveIconand #context-quickFoldersIcon.:

  folderPanePopup: function folderPanePopup(evt) {
      const util = QuickFolders.Util;
    try {
      let folders = GetSelectedMsgFolders(),
          folder = folders[0],
          hasIcon = QuickFolders.FolderTree.hasTreeItemFolderIcon(folder);
      util.$("context-quickFoldersRemoveIcon").collapsed = !hasIcon;
      util.$("context-quickFoldersIcon").collapsed = hasIcon; // hide select icon for tidier experience.
    }
    catch (ex) { util.logDebug("folderPanePopup() failed:" + ex);  }
  } 

I can remove that and use the API for generating these in case there is a bad side effect. Do you guys get extra logs when you right-click the junk folder (after enabling QuickFolders / Advanced Settings / Debug Mode) ??

Eccenux commented 1 year ago

I think you should not be using any ids that could resemble TB ids. You should probably also always refer to items by using some container that is specific to the addon. So ids like this would be better: quickfolders-folderPaneContext-emptyJunk.

Probably not:

   for (let p of document.querySelectorAll("#" + popupId)) {
      if (p!=passedPopup)
        p.parentNode.removeChild(p);
    }

Would be better (or similar):

   for (let p of document.querySelectorAll(".quickfolders #" + popupId)) {
      if (p!=passedPopup)
        p.parentNode.removeChild(p);
    }
RealRaven2000 commented 1 year ago

Here is a version with 2 changes - no listener on the folderpane menu, and I renamed the id #folderPaneContext-emptyJunk to #folderPaneContext-emptyJunk-QF (even though this last one shouldn't matter as I only read it and don't modify it anywhere).

QuickFolders-mx-6.3pre29.zip


To install, download the zip file and drag into Thunderbird Add-ons Manager (do not extract contents).

Also, you can try enabling/disabling the internal menu items in QF settings here: image

(these settings only affect the "mail commands" popup menu that is built when you click on a QuickFolders tab, but it's worth a shot maybe?)

Eccenux commented 1 year ago

Here is a version with 2 changes - no listener on the folderpane menu, and I renamed the id #folderPaneContext-emptyJunk to #folderPaneContext-emptyJunk-QF (even though this last one shouldn't matter as I only read it and don't modify it anywhere). QuickFolders-mx-6.3pre29.zip

That version fixed the junk folder. The Empty Trash action is still missing when you go into the trash folder.

Also, you can try enabling/disabling the internal menu items in QF settings here:

That didn't help. I already tried enabling/disabling the options.

I can remove that and use the API for generating these in case there is a bad side effect. Do you guys get extra logs when you right-click the junk folder (after enabling QuickFolders / Advanced Settings / Debug Mode) ??

None at the moment I click to open context menu. After playing a bit I saw this:

i18n.updateDocument options.js:840:9
loadPrefs options.js:529:11
QuickFolders 13:23:26.447  [171831 ms]   
 updateQuickFoldersLabel() quickfolders-util.js:1304:13
QuickFolders 13:23:26.471  [NaN ms]   
 Theme [flatTabs] selected options-util.js:134:13
Eccenux commented 1 year ago

This shows the problem: https://www.youtube.com/shorts/NfmAgsm3O7g

As you can see empty trash is gone when you go to Junk (Niechciane) directly and then go to Trash (Kosz) directly. Empty Trash in Polish is "Opróżnij kosz".

Eccenux commented 1 year ago

One more thing that might be important. The problem is gone when I disable QuickFolder. I don't need to unistall it. I don't need to restart TB. So that means two things for me:

  1. TB is either recreating menu or fixing it each time you open it.
  2. QuickFolders is doing dynamic manipulation (e.g. upon some event). That is actively braking the menu.
RealRaven2000 commented 1 year ago

One more thing that might be important. The problem is gone when I disable QuickFolder. I don't need to unistall it. I don't need to restart TB. So that means two things for me:

1. TB is either recreating menu or fixing it each time you open it.

2. QuickFolders is doing dynamic manipulation (e.g. upon some event). That is actively braking the menu.

So in detail, I think this happens. QuickFolders creates menu items with the same Id (when the cached popup menus for the QuickFolders tabs are built) - but it doesn't explicitly remove them. I think I used these in order to benefit from any automatic stylings (such as icons) that Thunderbird might add in the future (or have used in the past). I am more inclined towards styling via classes these days, as dealing with ids is messy - doubtlessly will be a big refactoring done, but quickfolders-layout.css and the rules are gruesomely complicated - especially since I allow the user to modify a lot of these styles. So the potential for breaking working stuff is astronomical.

The changed version I uploaded had a postfix -QF for the junk menu item but not for trash. So I am going to namespace these items and upload another version here next.

RealRaven2000 commented 1 year ago

Below is another test version - I namespaced anything starting with the string folderPaneContext- with a QF_ prefix, for example #QF_folderPaneContext-downloadAll for the command to download all mails for a specific IMAP folder. Note that you may have to restart Thunderbird to force refreshing the styles (because Tb just like Firefox caches style sheets during the session). So you will only see the icon after restart:

image

QuickFolders-mx-6.3pre31.zip


To install, download the zip file and drag into Thunderbird Add-ons Manager (do not extract contents).

crablouis commented 11 months ago

I'm still having this issue.

(NB - I have not rebuilt my TB profile... )

RealRaven2000 commented 11 months ago
  • Do you recommend installing the above ZIP, or awaiting fix though your normal update channel?

yes, that's what it is there for. Always download the prerelease, test again and report back if you can, because if I say "it is fixed" in the comment I assume my work in the issue is "done".

Note that I use always increasing version numbers (pre123, pre124 etc.) so a newer release will always replace test versions automatically. One rule that applies here is (6.3 > 6.3pre*).

Below is the very latest version for testing, including the empty junk fix:

QuickFolders-mx-6.3pre102.zip

This one also includes the latest fixes from #398, #399, #400, #404, #406, #407, #408, #409 and #412.


To install, download the zip file and drag into Thunderbird Add-ons Manager (do not extract contents).

crablouis commented 11 months ago

So far so good. It's working! Thanks Axel.

RealRaven2000 commented 11 months ago

Fixed in 6.3 - Published 30/10/2023