diff options
| author | Eltrac <hi@guhub.cn> | 2025-09-10 18:18:32 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-09-10 18:18:32 +0800 |
| commit | e0b38e398d35c5c809aaa462b50e483e53d2edbc (patch) | |
| tree | 67c085ef51d76d66fafa48c50ce18703cf1cc7e8 /assets | |
| parent | c34851282a3055d4d8d004cd3379d402cd3c3c4e (diff) | |
refactor: use existence instead of boolean string in local storage
Umami needs `umami.disabled` value to be `1` to actually disable it. Also, local storage can't store booleans, hence 'true' and 'false' are stored as strings, which is dumb. Just remove the item when it needs to be set false.
Former-commit-id: 165abe4eaf4597d7b8e64ec245bd2036a3ec02df
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/js/settings.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/assets/js/settings.js b/assets/js/settings.js index 053786d6..52675143 100644 --- a/assets/js/settings.js +++ b/assets/js/settings.js @@ -96,7 +96,10 @@ // add event listener to checkbox element.addEventListener('change', () => { - localStorage.setItem(checkboxOption.storage, element.checked); + if (element.checked) + localStorage.setItem(checkboxOption.storage, 1); + else + localStorage.removeItem(checkboxOption.storage); }); // append checkbox and label to container |
