@@ -43,11 +43,18 @@ function getSettingValue(settingName) {
4343}
4444
4545function isUsingSystemTheme ( ) {
46- const current = getSettingValue ( "theme" ) ;
46+ const current = getTheme ( ) ;
4747 return current === null || current === "system-preference" ;
4848}
4949
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+ }
5158
5259const savedHref = [ ] ;
5360
@@ -200,7 +207,7 @@ const updateSystemTheme = (function() {
200207 // the user disables "use-system-theme" and reloads the page or
201208 // navigates to another page
202209 } else {
203- use ( getSettingValue ( "theme" ) , true ) ;
210+ use ( getTheme ( ) , true ) ;
204211 }
205212 }
206213
@@ -215,18 +222,18 @@ function switchToSavedTheme() {
215222 switchTheme (
216223 window . currentTheme ,
217224 window . mainTheme ,
218- getSettingValue ( "theme" ) || "light" ,
225+ getTheme ( ) || "light" ,
219226 false
220227 ) ;
221228}
222229
223230if ( isUsingSystemTheme ( ) && window . matchMedia ) {
224231 // update the preferred dark theme if the user is already using a dark theme
225232 // See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
226- if ( getSettingValue ( "theme" ) === null
233+ if ( getTheme ( ) === null
227234 && 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 ( ) ) ;
230237 }
231238
232239 // call the function to initialize the theme at least once!
0 commit comments