Use getPreference* instead of accessing localStorage directly

This commit is contained in:
novenary
2023-02-02 15:25:45 +02:00
parent d980edd843
commit 7b832a981c
4 changed files with 17 additions and 9 deletions

View File

@@ -162,6 +162,15 @@ const mixin = {
return Number(value);
} else return defaultVal;
},
getPreferenceJSON(key, defaultVal) {
var value;
if (
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
(this.testLocalStorage && (value = localStorage.getItem(key)) !== null)
) {
return JSON.parse(value);
} else return defaultVal;
},
apiUrl() {
return this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
},