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,16 +49,10 @@ export class TalkgroupService {
} }
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> { getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
const key = this.tgKey(sys, tg);
if (!this._getTalkgroup.get(key)) {
return this.tgs$.pipe( return this.tgs$.pipe(
switchMap((talkg) => switchMap((tgs) => tgs.filter(t => t.system_id === sys && t.tgid === tg))
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> {
let tgid = this.tgKey(tu.system_id, tu.tgid); let tgid = this.tgKey(tu.system_id, tu.tgid);