-
-
Notifications
You must be signed in to change notification settings - Fork 745
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
feat: re-implement ContextMenu
& Menu
#2776
Conversation
With the last commit, the Profile menu is also handled in the exact same way as the Context Menu. |
ContextMenu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm against:
- having
ContextMenu
andContextMenuV2
- using
webpack-loaded
event
ContextMenuV2 is temporary and should replace ContextMenu & Menu in the future.
I have to disagree here, this is a perfect use case for using events, but I guess I can expose an onWebpackLoaded function that takes care of listening to the event & checking if it's already loaded. |
may i ask if this rewrite will potentially solve this issue #2757? |
In other words, you said yourself that this is something for Spicetify v3. I agree, which is why I'm against it |
nvm, just rename it to |
This doesn't have to wait until V3, it is a drop-in replacement that works NOW. Why wait on a feature that doesn't break any existing API. |
Are you referring to this commit: 7ed19b9 ? Loading and order of execution for the different helper scripts and extensions should be revised in V3 to reduce the async mess, and not have extension developers check for whatever |
Now I'm against
No, I want the event to be renamed
Because no one will use it until we force them to. And I don't see a reason to do that. Actually, all the breaking changes can be done without releasing v3 if we don't touch the current code and just add the SpicetifyV3 object. /s |
No, as usual I got it right at once, but then mistakenly doubted myself. I'm against using the event too, since you don't check |
Not if they would be already using it; ContextMenu & Menu are like adapters, you can use them the old way and they translate to the newer implementation. Why don't you want to wait on it? Because this implementation:
|
as I said:
If you want to implement something like this, at least:
|
no other questions atm |
There is no event.
And take a course on formal methods too? \s
Spicetify.test() is only meant for testing environment / as a debugging tool. Not to be run for everyone on startup. But if you insist on doing it your way, then you have to rethink how props are loaded. Probably something like: prop = assertNonNullAndReturn() and fire a groupA loaded event/callback at the end of the block, then try catch on the outer scope. |
this ^ |
But keeping spicetify installation updated is not
Oh, right, you've removed the event and added a non-react hook. Don't understand why
No, it is not. If it was, |
The step that's supposed to assign the prop failed... ergo The prop will never be assigned... Extension developer can do as he pleases, but the prop will NEVER be available, they can be an idiot and fallback to a useless setTimeout, or define a fallback prop or panic or whatever. |
so all hooks are done after |
Lmfao, wtf man. Can't you take a look at spicetifyWrapper.js? onLoadedWebpackModules's callbacks are called when all the Spicetify props set inside hotloadWebpackModules are set. |
For example, Spicetify.Keyboard waits for Spicetify.Mousetrap which is exposed through webpackModules. |
I was speaking about the hooks all the time, not about "all spicetify props" But ok, this dialog has clearly reached an impasse To summarize:
That's all rn |
Solution that you proposed is simply to wait for V3 and release a breaking change.
Can't split the PR into two because the Menu changes make it depend on React, and the jsHelpers are run before Spicetify.React is loaded. |
would a non-react hook solve #2757 |
Only way to use spotify's context menus is through the ReactComponent, so you have to use it. But if you don't wish to use react to generate the children dom tree then you have to use a useRef hook and create a div with react and ref passed to props. Then you can treat that ref as any other normal HTML element. |
ah that makes sense, thank you! ❤️ |
ContextMenu
ContextMenu
& Menu
Reopened as requested by @rxri.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else looks alright, but I'll give it a re-review later
merging to prod without testing xoxo /s |
This is a fully backward-compatible rewrite of Context Menus, it doesn't rely on "injecting" HTML elements using Dom-manipulation or mutation observers.
Instead, it directly patches Spotify's react components for the context menu, at two different places, first to extract
[uris, uids, contextUri, ...
and expose them with a react context. And second, extend thechildren
prop from the container.This change makes the code significantly easier to understand, as it no longer relies on internal tippy features. It also fixes the long-standing issue of open Spotify sub-menus not closing after you hover over a Spicetify injected item.