132
132
133
133
( function waitForRemoteConfigResolver ( ) {
134
134
// 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 ) ) {
136
136
setTimeout ( waitForRemoteConfigResolver , 500 ) ;
137
137
return ;
138
138
}
139
139
140
140
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
+ } ;
142
159
143
- ( function waitForResolver ( ) {
144
- if ( ! Spicetify . RemoteConfigResolver ) {
160
+ ( async function waitForResolver ( ) {
161
+ if ( ! Spicetify . RemoteConfigResolver && ! Spicetify . Platform ?. RemoteConfigDebugAPI ) {
145
162
isFallback = true ;
146
163
notice . innerText = "⚠️ Using fallback mode. Some features may not work." ;
147
164
setTimeout ( waitForResolver , 500 ) ;
148
165
return ;
149
166
}
150
167
isFallback = false ;
151
168
notice . remove ( ) ;
152
- remoteConfiguration = Spicetify . RemoteConfigResolver . value . remoteConfiguration ;
153
- setOverrides = Spicetify . RemoteConfigResolver . value . setOverrides ;
169
+ remoteConfiguration = Spicetify ?. RemoteConfigResolver ?. remoteConfiguration ?? ( await Spicetify . Platform ?. RemoteConfigDebugAPI . getProperties ( ) ) ;
154
170
} ) ( ) ;
155
171
156
172
for ( const key of Object . keys ( overrideList ) ) {
165
181
localStorage . setItem ( "spicetify-exp-features" , JSON . stringify ( overrideList ) ) ;
166
182
167
183
featureMap [ name ] = value ;
168
- setOverrides ( Spicetify . createInternalMap ?. ( featureMap ) ) ;
184
+ setOverrides ( { [ name ] : value } ) ;
169
185
}
170
186
171
187
function createSlider ( name , desc , defaultVal ) {
@@ -254,8 +270,12 @@ ${Spicetify.SVGIcons.search}
254
270
255
271
for ( const name of Object . keys ( overrideList ) ) {
256
272
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 } ) ;
259
279
}
260
280
261
281
const feature = overrideList [ name ] ;
@@ -269,8 +289,6 @@ ${Spicetify.SVGIcons.search}
269
289
}
270
290
271
291
content . appendChild ( resetButton ) ;
272
-
273
- setOverrides ( Spicetify . createInternalMap ?. ( featureMap ) ) ;
274
292
} ) ( ) ;
275
293
276
294
await new Promise ( ( res ) => Spicetify . Events . webpackLoaded . on ( res ) ) ;
0 commit comments