mozillabrasil / sumo_live_helper

Helper Add-on for SUMO forum contributors
https://addons.mozilla.org/firefox/addon/sumo-live-helper-/
Mozilla Public License 2.0
7 stars 8 forks source link

Toggle sidebar when clicking on browserAction icon #116

Closed dannycolin closed 3 years ago

dannycolin commented 4 years ago

Step to reproduce

  1. Set "Always open questions in sidebar" in Preferences
  2. Click on SUMO Live Helper browserAction icon to open the sidebar
  3. Re-click to close the sidebar

Actual Behavior

If the sidebar is open and I click on the browserAction icon, it doesn't close the sidebar like it doesn't with the builtin sidebar icon.

Expected Behavior

The browserAction icon should toggle on and off the sidebar when we click on it.

WesleyBranton commented 4 years ago

This was originally how I intended it to work, but there are some limitations to the sidebarAction API that prevented it from working properly. Doing this would require a check to see if the sidebar is currently opening. There is an API for that, but it returns a promise. The problem is that using the open() or close() features will not allow the code to wait for a promise.

It's quite easy to check if the sidebar is open, but it's not so easy when you can't use the promise from the built-in API. I played around a bit with having a sidebarIsOpen boolean variable and just periodically running a function that updated that value, but I couldn't find a reliable way to trigger that function so that the value in the variable will always be accurate.

Since I couldn't get that functionality working, I omitted it from the release. I can look at it some more and see if there is a good way to do it for a future release, but there's no guarantee that there is a way to do it.

dannycolin commented 4 years ago

Since I couldn't get that functionality working, I omitted it from the release. I can look at it some more and see if there is a good way to do it for a future release, but there's no guarantee that there is a way to do it.

No rush. We can put it in the "nice to have" list and focus on more urgent issues ;).