fix api spam
This commit is contained in:
parent
4d2eaefe1f
commit
185237cd01
1 changed files with 3 additions and 6 deletions
|
@ -33,7 +33,7 @@ export class TalkgroupService {
|
||||||
private subscriptions = new Subscription();
|
private subscriptions = new Subscription();
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
this.tgs$ = this.fetchAll.pipe(switchMap(() => this.getTalkgroups()));
|
this.tgs$ = this.fetchAll.pipe(switchMap(() => this.getTalkgroups()));
|
||||||
this.tags$ = this.fetchAll.pipe(switchMap(() => this.getAllTags()));
|
this.tags$ = this.fetchAll.pipe(switchMap(() => this.getAllTags()), shareReplay());
|
||||||
this.fillTgMap();
|
this.fillTgMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,11 +52,8 @@ export class TalkgroupService {
|
||||||
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
|
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
|
||||||
const key = this.tgKey(sys, tg);
|
const key = this.tgKey(sys, tg);
|
||||||
if (!this._getTalkgroup.get(key)) {
|
if (!this._getTalkgroup.get(key)) {
|
||||||
return this.tgs$.pipe(
|
let rs = new ReplaySubject<Talkgroup>();
|
||||||
switchMap((talkg) =>
|
this._getTalkgroup.set(key, rs);
|
||||||
talkg.filter((tgv) => tgv.tgid == tg && tgv.system_id == sys),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return this._getTalkgroup.get(key)!;
|
return this._getTalkgroup.get(key)!;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue