132132
133133 ( function waitForRemoteConfigResolver ( ) {
134134 // Don't show options if hooks aren't patched/loaded
135- if ( ! hooksPatched || ( ! Spicetify . RemoteConfigResolver && ! Spicetify . Platform ?. RemoteConfiguration ) ) {
135+ if ( ! hooksPatched || ( ! Spicetify . RemoteConfigResolver && ! Spicetify . Platform ?. RemoteConfigDebugAPI && ! Spicetify . Platform ?. RemoteConfiguration ) ) {
136136 setTimeout ( waitForRemoteConfigResolver , 500 ) ;
137137 return ;
138138 }
139139
140140 let remoteConfiguration = Spicetify . RemoteConfigResolver ?. value . remoteConfiguration || Spicetify . Platform ?. RemoteConfiguration ;
141- let setOverrides = ( ) => { } ;
141+ const setOverrides = async ( overrides ) => {
142+ if ( Spicetify . Platform ?. RemoteConfigDebugAPI ) {
143+ for ( const [ name , value ] of Object . entries ( overrides ) ) {
144+ const feature = overrideList [ name ] ;
145+ const type = feature . values ? "enum" : typeof value === "number" ? "number" : "boolean" ;
146+ await Spicetify . Platform . RemoteConfigDebugAPI . setOverride (
147+ {
148+ source : "web" ,
149+ type,
150+ name,
151+ } ,
152+ value
153+ ) ;
154+ }
155+ } else if ( Spicetify . RemoteConfigResolver ?. value ?. setOverrides ) {
156+ Spicetify . RemoteConfigResolver . value . setOverrides ( Spicetify . createInternalMap ?. ( overrides ) ) ;
157+ }
158+ } ;
142159
143- ( function waitForResolver ( ) {
144- if ( ! Spicetify . RemoteConfigResolver ) {
160+ ( async function waitForResolver ( ) {
161+ if ( ! Spicetify . RemoteConfigResolver && ! Spicetify . Platform ?. RemoteConfigDebugAPI ) {
145162 isFallback = true ;
146163 notice . innerText = "⚠️ Using fallback mode. Some features may not work." ;
147164 setTimeout ( waitForResolver , 500 ) ;
148165 return ;
149166 }
150167 isFallback = false ;
151168 notice . remove ( ) ;
152- remoteConfiguration = Spicetify . RemoteConfigResolver . value . remoteConfiguration ;
153- setOverrides = Spicetify . RemoteConfigResolver . value . setOverrides ;
169+ remoteConfiguration = Spicetify ?. RemoteConfigResolver ?. remoteConfiguration ?? ( await Spicetify . Platform ?. RemoteConfigDebugAPI . getProperties ( ) ) ;
154170 } ) ( ) ;
155171
156172 for ( const key of Object . keys ( overrideList ) ) {
165181 localStorage . setItem ( "spicetify-exp-features" , JSON . stringify ( overrideList ) ) ;
166182
167183 featureMap [ name ] = value ;
168- setOverrides ( Spicetify . createInternalMap ?. ( featureMap ) ) ;
184+ setOverrides ( { [ name ] : value } ) ;
169185 }
170186
171187 function createSlider ( name , desc , defaultVal ) {
@@ -254,8 +270,12 @@ ${Spicetify.SVGIcons.search}
254270
255271 for ( const name of Object . keys ( overrideList ) ) {
256272 if ( ! prevSessionOverrideList . includes ( name ) && remoteConfiguration . values . has ( name ) ) {
257- changeValue ( name , remoteConfiguration . values . get ( name ) ) ;
258- console . log ( name , remoteConfiguration . values . get ( name ) , overrideList [ name ] ) ;
273+ const currentValue = remoteConfiguration . values . get ( name ) ;
274+ overrideList [ name ] . value = currentValue ;
275+ localStorage . setItem ( "spicetify-exp-features" , JSON . stringify ( overrideList ) ) ;
276+
277+ featureMap [ name ] = currentValue ;
278+ setOverrides ( { [ name ] : currentValue } ) ;
259279 }
260280
261281 const feature = overrideList [ name ] ;
@@ -269,8 +289,6 @@ ${Spicetify.SVGIcons.search}
269289 }
270290
271291 content . appendChild ( resetButton ) ;
272-
273- setOverrides ( Spicetify . createInternalMap ?. ( featureMap ) ) ;
274292 } ) ( ) ;
275293
276294 await new Promise ( ( res ) => Spicetify . Events . webpackLoaded . on ( res ) ) ;
0 commit comments