Closed cyfung1031 closed 9 months ago
Thanks for the suggestion. The general idea is good, but see the comments.
If you're not interested in adjusting the PR, let me know (or just don't say anything for a bit) and I'll do it myself, but not sure if you'll get credit in git history if I do it that way.
Thanks for the review. It's almost 2 months ago I forgot this PR too. Understand your points. Let me check later and get back you :)
@JasonBarnabe I have changed the code as per your request. The event listener is now scoped inside canInstallUserCSS()
and to be removed after timeout or detection.
localStorage's stylusDetected
can be also removed if you want.
I deployed this and tried it out and it didn't work. Seems like the message listener never fired for the style-version
response from Stylus. Not sure why. I backed it out.
I believe it may be because Stylus will only respond once and there's another query happening in managers.js.
The previous code added the message listener immediately whereas yours only does so when the button is pressed, but by that time, Stylus has already fired its one and only message.
Noted. Let me check it again later :)
The
200ms
shall not be necessary since thePromise
can be directly resolved byonMessage