@@ -1745,14 +1745,19 @@ Spicetify.ContextMenuV2 = (() => {
1745
1745
}
1746
1746
1747
1747
class ItemSubMenu {
1748
- static itemsToComponents = ( items ) => items . map ( ( item ) => item . _element ) ;
1748
+ static itemsToComponents = ( items , props , trigger , target ) => {
1749
+ return items
1750
+ . filter ( ( item ) => ( item . shouldAdd || ( ( ) => true ) ) ?. ( props , trigger , target ) )
1751
+ . map ( ( item ) => item . _element ) ;
1752
+ } ;
1749
1753
1750
1754
constructor ( { text, disabled = false , leadingIcon, divider, items, shouldAdd = ( ) => true } ) {
1751
1755
this . shouldAdd = shouldAdd ;
1752
1756
1753
1757
this . _text = text ;
1754
1758
this . _disabled = disabled ;
1755
1759
this . _leadingIcon = leadingIcon ;
1760
+ this . _divider = divider ;
1756
1761
this . _items = items ;
1757
1762
this . _element = Spicetify . ReactJSX . jsx ( ( ) => {
1758
1763
const [ _text , setText ] = Spicetify . React . useState ( this . _text ) ;
@@ -1776,6 +1781,9 @@ Spicetify.ContextMenuV2 = (() => {
1776
1781
} ;
1777
1782
} ) ;
1778
1783
1784
+ const context = Spicetify . React . useContext ( Spicetify . ContextMenuV2 . _context ) ?? { } ;
1785
+ const { props, trigger, target } = context ;
1786
+
1779
1787
return Spicetify . React . createElement ( Spicetify . ReactComponent . MenuSubMenuItem , {
1780
1788
displayText : _text ,
1781
1789
divider : _divider ,
@@ -1785,7 +1793,7 @@ Spicetify.ContextMenuV2 = (() => {
1785
1793
onClick : ( ) => undefined ,
1786
1794
disabled : _disabled ,
1787
1795
leadingIcon : _leadingIcon && createIconComponent ( _leadingIcon ) ,
1788
- children : ItemSubMenu . itemsToComponents ( _items ) ,
1796
+ children : ItemSubMenu . itemsToComponents ( _items , props , trigger , target ) ,
1789
1797
} ) ;
1790
1798
} , { } ) ;
1791
1799
}
0 commit comments