mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Fix bug with local storage avoids read back
This commit is contained in:
parent
a189be48db
commit
f1bfeaa3a5
|
|
@ -6,7 +6,6 @@ import { RadioAvoids, RadioCall, RadioCalls, RadioEvent, RadioSystem, RadioSyste
|
||||||
|
|
||||||
const LOCAL_STORAGE_KEY = {
|
const LOCAL_STORAGE_KEY = {
|
||||||
avoids: 'radio-avoids',
|
avoids: 'radio-avoids',
|
||||||
live: 'radio-live',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
@ -54,9 +53,7 @@ export class AppRadioService implements OnDestroy {
|
||||||
|
|
||||||
this._readAvoids();
|
this._readAvoids();
|
||||||
|
|
||||||
this._subscribeSystems().then(() => {
|
this._subscribeSystems();
|
||||||
// this._readLive();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
|
@ -170,8 +167,6 @@ export class AppRadioService implements OnDestroy {
|
||||||
|
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._writeLive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
play(call?: RadioCall): void {
|
play(call?: RadioCall): void {
|
||||||
|
|
@ -375,14 +370,6 @@ export class AppRadioService implements OnDestroy {
|
||||||
this._emitAvoidsEvent();
|
this._emitAvoidsEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _readLive(): void {
|
|
||||||
const live = this._readLocalStorage(LOCAL_STORAGE_KEY.live);
|
|
||||||
|
|
||||||
if (live !== false) {
|
|
||||||
this.liveFeed(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _readLocalStorage(key: string): any {
|
private _readLocalStorage(key: string): any {
|
||||||
if (window instanceof Window && window.localStorage instanceof Storage) {
|
if (window instanceof Window && window.localStorage instanceof Storage) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -457,16 +444,18 @@ export class AppRadioService implements OnDestroy {
|
||||||
})
|
})
|
||||||
.pipe(debounceTime(100))
|
.pipe(debounceTime(100))
|
||||||
.subscribe((systems: RadioSystem[]) => {
|
.subscribe((systems: RadioSystem[]) => {
|
||||||
this._systems.splice(0, this._systems.length, ...systems);
|
if (systems.length) {
|
||||||
|
this._systems.splice(0, this._systems.length, ...systems);
|
||||||
|
|
||||||
this._emitSystemsEvent();
|
this._emitSystemsEvent();
|
||||||
|
|
||||||
this._syncAvoids();
|
this._syncAvoids();
|
||||||
this._writeAvoids();
|
this._writeAvoids();
|
||||||
|
|
||||||
if (!hasInitialize) {
|
if (!hasInitialize) {
|
||||||
hasInitialize = true;
|
hasInitialize = true;
|
||||||
resolve();
|
resolve();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -539,10 +528,6 @@ export class AppRadioService implements OnDestroy {
|
||||||
this._writeLocalStorage(LOCAL_STORAGE_KEY.avoids, avoids);
|
this._writeLocalStorage(LOCAL_STORAGE_KEY.avoids, avoids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _writeLive(): void {
|
|
||||||
this._writeLocalStorage(LOCAL_STORAGE_KEY.live, this.live);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _writeLocalStorage(key: string, value: any): void {
|
private _writeLocalStorage(key: string, value: any): void {
|
||||||
if (window instanceof Window && window.localStorage instanceof Storage) {
|
if (window instanceof Window && window.localStorage instanceof Storage) {
|
||||||
window.localStorage.setItem(key, JSON.stringify(value));
|
window.localStorage.setItem(key, JSON.stringify(value));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue