fix api spam

This commit is contained in:
Daniel Ponte 2025-01-11 16:38:27 -05:00
parent 4d2eaefe1f
commit 185237cd01

View file

@ -33,7 +33,7 @@ export class TalkgroupService {
private subscriptions = new Subscription();
constructor(private http: HttpClient) {
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();
}
@ -52,11 +52,8 @@ export class TalkgroupService {
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
const key = this.tgKey(sys, tg);
if (!this._getTalkgroup.get(key)) {
return this.tgs$.pipe(
switchMap((talkg) =>
talkg.filter((tgv) => tgv.tgid == tg && tgv.system_id == sys),
),
);
let rs = new ReplaySubject<Talkgroup>();
this._getTalkgroup.set(key, rs);
}
return this._getTalkgroup.get(key)!;
}