Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button enhancements #7

Open
CharoSW opened this issue Jan 23, 2018 · 6 comments
Open

Button enhancements #7

CharoSW opened this issue Jan 23, 2018 · 6 comments

Comments

@CharoSW
Copy link

CharoSW commented Jan 23, 2018

Would it be possible to have a couple of enhancements to the button. Firstly that it toggles the download sidebar rather than just only open it. Secondly that the icon either has a light version for dark firefox themes or is neutral and thus changes with the toolbar text color. I'm not sure how that can be achieved but there's probably an example somewhere

@dfalling
Copy link

I'd also love if right-clicking the button had a clear downloads option.

@josalhor
Copy link
Contributor

I believe the toggle should be fairly easy to implement. I'll do that today when I get home today.
I have no idea how to implement the right click tho, I can't find an API that would allow such thing,

@josalhor
Copy link
Contributor

I haven't succeed implementing the toggle. I believe some security features are blocking what I'm trying to do.

The on click callback I was trying to implement checked whether or not the current sidebar is open. Whoever the function that gives me that information returns a Promise and when I append the callback to the promise then FF tells me I'm trying to close the sidebar from a function that was not interacting with the user (and that is not allowed!)

Trying to wait for the Promise makes the original callback async, and the same problem arises.

I've only been successful modifying a global variable, but still it wasn't working right. It needed two clicks to work properly, one for updating the variable and another for closing it.

I have a feeling some kind of nasty trick could be applied to make it work and wait for the promise, but I wouldn't want to do that. I'll keep trying, it is possible I could do something different (first time using Promises in JS!).

About the right click, I still haven't found anything and I don't think WebExtensions have anything like that, I'll keep looking tho.

@dfalling
Copy link

@josalhor do you have a branch with your work attempting this? I haven't worked on web extensions at all but have a good understanding of JS and promises and can try to help out.

@josalhor
Copy link
Contributor

Here you go: https://github.com/josalhor/firefox-downloads-sidebar/commit/08846b22113e986585bdd725c08eb21f712fdc1c

That implementation fails telling me Error: sidebarAction.close may only be called from a user input handler

@dfalling
Copy link

@josalhor Oof yeah, there's no easy fix for that. There are a few bugs logged about that: 1438465, 1398833. A bigger workaround would maybe be to keep track of when the sidebar is visible in storage and use that instead of sidebarAction.isOpen.

But your promise code looks good! It's just an issue with Firefox that doesn't have a great workaround currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants