@@ -43,11 +43,18 @@ function getSettingValue(settingName) {
43
43
}
44
44
45
45
function isUsingSystemTheme ( ) {
46
- const current = getSettingValue ( "theme" ) ;
46
+ const current = getTheme ( ) ;
47
47
return current === null || current === "system-preference" ;
48
48
}
49
49
50
- const localStoredTheme = getSettingValue ( "theme" ) ;
50
+ function getTheme ( ) {
51
+ const current = getSettingValue ( "theme2" ) ;
52
+ if ( current === null ) {
53
+ // We try to get what's being used in the previous version.
54
+ return getSettingValue ( "theme" ) ;
55
+ }
56
+ return current ;
57
+ }
51
58
52
59
const savedHref = [ ] ;
53
60
@@ -200,7 +207,7 @@ const updateSystemTheme = (function() {
200
207
// the user disables "use-system-theme" and reloads the page or
201
208
// navigates to another page
202
209
} else {
203
- use ( getSettingValue ( "theme" ) , true ) ;
210
+ use ( getTheme ( ) , true ) ;
204
211
}
205
212
}
206
213
@@ -215,18 +222,18 @@ function switchToSavedTheme() {
215
222
switchTheme (
216
223
window . currentTheme ,
217
224
window . mainTheme ,
218
- getSettingValue ( "theme" ) || "light" ,
225
+ getTheme ( ) || "light" ,
219
226
false
220
227
) ;
221
228
}
222
229
223
230
if ( isUsingSystemTheme ( ) && window . matchMedia ) {
224
231
// update the preferred dark theme if the user is already using a dark theme
225
232
// See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
226
- if ( getSettingValue ( "theme" ) === null
233
+ if ( getTheme ( ) === null
227
234
&& getSettingValue ( "preferred-dark-theme" ) === null
228
- && darkThemes . indexOf ( localStoredTheme ) >= 0 ) {
229
- updateLocalStorage ( "preferred-dark-theme" , localStoredTheme ) ;
235
+ && darkThemes . indexOf ( getTheme ( ) ) >= 0 ) {
236
+ updateLocalStorage ( "preferred-dark-theme" , getTheme ( ) ) ;
230
237
}
231
238
232
239
// call the function to initialize the theme at least once!
0 commit comments