@@ -1748,37 +1748,46 @@ Spicetify.ContextMenuV2 = (() => {
17481748 }
17491749
17501750 class ItemSubMenu {
1751- static itemsToComponents = ( items , props , trigger , target ) => {
1752- return items . filter ( ( item ) => ( item . shouldAdd || ( ( ) => true ) ) ?. ( props , trigger , target ) ) . map ( ( item ) => item . _element ) ;
1753- } ;
1751+ static itemsToComponents ( items , props , trigger , target , parentDepth = 1 ) {
1752+ return items
1753+ . filter ( ( item ) => ( item . shouldAdd || ( ( ) => true ) ) ?. ( props , trigger , target ) )
1754+ . map ( ( item ) => {
1755+ if ( item instanceof ItemSubMenu ) item . depth = parentDepth + 1 ;
1756+ return item . _element ;
1757+ } ) ;
1758+ }
17541759
1755- constructor ( { text, disabled = false , leadingIcon, divider, items, shouldAdd = ( ) => true } ) {
1760+ constructor ( { text, disabled = false , leadingIcon, divider, items, depth = 1 , shouldAdd = ( ) => true } ) {
17561761 this . shouldAdd = shouldAdd ;
17571762
17581763 this . _text = text ;
17591764 this . _disabled = disabled ;
17601765 this . _leadingIcon = leadingIcon ;
17611766 this . _divider = divider ;
17621767 this . _items = items ;
1768+ this . _depth = depth ;
17631769 this . _element = Spicetify . ReactJSX . jsx ( ( ) => {
17641770 const [ _text , setText ] = Spicetify . React . useState ( this . _text ) ;
17651771 const [ _disabled , setDisabled ] = Spicetify . React . useState ( this . _disabled ) ;
17661772 const [ _leadingIcon , setLeadingIcon ] = Spicetify . React . useState ( this . _leadingIcon ) ;
17671773 const [ _divider , setDivider ] = Spicetify . React . useState ( this . _divider ) ;
17681774 const [ _items , setItems ] = Spicetify . React . useState ( this . _items ) ;
1775+ const [ _depth , setDepth ] = Spicetify . React . useState ( this . _depth ) ;
17691776
17701777 Spicetify . React . useEffect ( ( ) => {
17711778 this . _setText = setText ;
17721779 this . _setDisabled = setDisabled ;
17731780 this . _setLeadingIcon = setLeadingIcon ;
17741781 this . _setDivider = setDivider ;
17751782 this . _setItems = setItems ;
1783+ this . _setDepth = setDepth ;
17761784 return ( ) => {
17771785 this . _setText = undefined ;
17781786 this . _setDisabled = undefined ;
17791787 this . _setLeadingIcon = undefined ;
17801788 this . _setDivider = undefined ;
17811789 this . _setItems = undefined ;
1790+ this . _setDepth = undefined ;
17821791 } ;
17831792 } ) ;
17841793
@@ -1788,13 +1797,13 @@ Spicetify.ContextMenuV2 = (() => {
17881797 return Spicetify . React . createElement ( Spicetify . ReactComponent . MenuSubMenuItem , {
17891798 displayText : _text ,
17901799 divider : _divider ,
1791- depth : 1 ,
1800+ depth : _depth ,
17921801 placement : "right-start" ,
17931802 onOpenChange : ( ) => undefined ,
17941803 onClick : ( ) => undefined ,
17951804 disabled : _disabled ,
17961805 leadingIcon : _leadingIcon && createIconComponent ( _leadingIcon ) ,
1797- children : ItemSubMenu . itemsToComponents ( _items , props , trigger , target ) ,
1806+ children : ItemSubMenu . itemsToComponents ( _items , props , trigger , target , _depth ) ,
17981807 } ) ;
17991808 } , { } ) ;
18001809 }
@@ -1831,6 +1840,14 @@ Spicetify.ContextMenuV2 = (() => {
18311840 return this . _divider ;
18321841 }
18331842
1843+ set depth ( value ) {
1844+ this . _depth = value ;
1845+ this . _setDepth ?. ( this . _depth ) ;
1846+ }
1847+ get depth ( ) {
1848+ return this . _depth ;
1849+ }
1850+
18341851 addItem ( item ) {
18351852 this . _items . add ( item ) ;
18361853 this . _setItems ?. ( this . _items ) ;
0 commit comments