This commit is contained in:
Daniel Ponte 2024-12-30 16:58:02 -05:00
parent 0035828965
commit 086bb90064

View file

@ -26,7 +26,6 @@ export interface TalkgroupsPaginated {
providedIn: 'root', providedIn: 'root',
}) })
export class TalkgroupService { export class TalkgroupService {
private readonly _getTalkgroup = new Map<string, ReplaySubject<Talkgroup>>();
private tgs$: Observable<Talkgroup[]>; private tgs$: Observable<Talkgroup[]>;
private tags$!: Observable<string[]>; private tags$!: Observable<string[]>;
private fetchAll = new BehaviorSubject<'fetch'>('fetch'); private fetchAll = new BehaviorSubject<'fetch'>('fetch');
@ -50,15 +49,9 @@ export class TalkgroupService {
} }
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> { getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
const key = this.tgKey(sys, tg); return this.tgs$.pipe(
if (!this._getTalkgroup.get(key)) { switchMap((tgs) => tgs.filter(t => t.system_id === sys && t.tgid === tg))
return this.tgs$.pipe( );
switchMap((talkg) =>
talkg.filter((tgv) => tgv.tgid == tg && tgv.system_id == sys),
),
);
}
return this._getTalkgroup.get(key)!;
} }
putTalkgroup(tu: TalkgroupUpdate): Observable<Talkgroup> { putTalkgroup(tu: TalkgroupUpdate): Observable<Talkgroup> {