Skip to content

Commit d2e1ea0

Browse files
committed
Fix LocalStorage boolean interpretation
1 parent 1bd3197 commit d2e1ea0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

bughog/web/vue/src/composables/useEvalParams.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,27 @@ const DEFAULT_EVAL_PARAMS = {
3030
experiment_to_plot: null,
3131
};
3232

33+
function getFromLocalStorage(param_name) {
34+
var param_value = localStorage.getItem(param_name);
35+
// LocalStorage only stores strings, so we will convert stringified booleans to actual booleans.
36+
if (param_value === 'true') {
37+
return true;
38+
} else if (param_value === 'false') {
39+
return false;
40+
}
41+
return param_value;
42+
}
43+
3344
function loadPersistedParams() {
3445
var loaded_eval_params = {};
3546

3647
// Load general params.
3748
let param_value;
3849
for (const param_name of persisted_general_params) {
3950
if (process.env.NODE_ENV === "development") {
40-
param_value = localStorage.getItem(`dev_${param_name}`);
51+
param_value = getFromLocalStorage(`dev_${param_name}`);
4152
} else {
42-
param_value = localStorage.getItem(param_name);
53+
param_value = getFromLocalStorage(param_name)
4354
}
4455
if (param_value !== null) {
4556
loaded_eval_params[param_name] = param_value;

0 commit comments

Comments
 (0)