Skip to content

Commit

Permalink
Replaced skipStorage with saveTheme variable
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 21, 2019
1 parent c076d30 commit 1bd9424
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Expand Up @@ -914,7 +914,7 @@ themePicker.onblur = handleThemeButtonsBlur;
var but = document.createElement('button');
but.innerHTML = item;
but.onclick = function(el) {{
switchTheme(currentTheme, mainTheme, item);
switchTheme(currentTheme, mainTheme, item, true);
}};
but.onblur = handleThemeButtonsBlur;
themes.appendChild(but);
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/static/storage.js
Expand Up @@ -86,7 +86,7 @@ function getCurrentValue(name) {
return null;
}

function switchTheme(styleElem, mainStyleElem, newTheme, skipStorage) {
function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
var fullBasicCss = "rustdoc" + resourcesSuffix + ".css";
var fullNewTheme = newTheme + resourcesSuffix + ".css";
var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);
Expand All @@ -111,7 +111,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, skipStorage) {
styleElem.href = newHref;
// If this new value comes from a system setting or from the previously saved theme, no
// need to save it.
if (skipStorage !== true) {
if (saveTheme === true) {
updateLocalStorage("rustdoc-theme", newTheme);
}
}
Expand All @@ -123,4 +123,4 @@ function getSystemValue() {

switchTheme(currentTheme, mainTheme,
getCurrentValue("rustdoc-theme") || getSystemValue() || "light",
true);
false);

0 comments on commit 1bd9424

Please sign in to comment.