Merge pull request #600 from silentrald/bugfix/remember-playlist-sort

[bugfix] remember option for map and playlist sorting
This commit is contained in:
MathieuG-P
2024-10-22 20:00:58 +02:00
committed by GitHub
4 changed files with 40 additions and 16 deletions
@@ -30,7 +30,7 @@ export class ConfigurationService {
public get<Type>(key: string | DefaultConfigKey): Type {
const rawValue = (window.sessionStorage.getItem(key) ?? window.localStorage.getItem(key));
const tryParse = tryit<Type>(() => JSON.parse(rawValue));
const res = (tryParse.error ? rawValue : tryParse.result) as Type;
if(!res && Object.keys(defaultConfiguration).includes(key)){
@@ -40,7 +40,7 @@ export class ConfigurationService {
return res;
}
public set(key: string, value: unknown, persistant = true) {
public set(key: string | DefaultConfigKey, value: unknown, persistant = true) {
if(value != null){
this.getPropperStorage(persistant).setItem(key, JSON.stringify(value));
@@ -51,7 +51,7 @@ export class ConfigurationService {
this.emitChange(key);
}
public delete(key: string) {
public delete(key: string | DefaultConfigKey) {
window.localStorage.removeItem(key);
window.sessionStorage.removeItem(key);
this.emitChange(key);