broke authenticated tgs

This commit is contained in:
Daniel Ponte 2025-02-06 21:06:06 -05:00
parent 3e3d39332c
commit 57f6e1254b
2 changed files with 22 additions and 4 deletions

View file

@ -4,12 +4,21 @@ import { map, Observable, switchMap } from 'rxjs';
import { IncidentRecord } from '../incidents';
import { CallRecord } from '../calls';
import { Share, ShareType } from '../shares';
import { ActivatedRoute, Router } from '@angular/router';
@Injectable({
providedIn: 'root',
})
export class ShareService {
constructor(private http: HttpClient) {}
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute) {}
inShare(): string|null {
if(this.router.url.startsWith('/s/')) {
return this.route.snapshot.paramMap.get('id');
}
return null;
}
getShare(id: string): Observable<Share> {
return this.http.get<Share>(`/share/${id}`);

View file

@ -5,11 +5,13 @@ import {
Observable,
ReplaySubject,
shareReplay,
Subject,
Subscription,
switchMap,
} from 'rxjs';
import { Talkgroup, TalkgroupUpdate, TGID } from '../talkgroup';
import { Share } from '../shares';
import { ShareService } from '../share/share.service';
export interface Pagination {
page: number;
@ -29,9 +31,9 @@ export class TalkgroupService {
private readonly _getTalkgroup = new Map<string, ReplaySubject<Talkgroup>>();
private tgs$: Observable<Talkgroup[]>;
private tags$!: Observable<string[]>;
private fetchAll = new BehaviorSubject<Share|null>(null);
private fetchAll = new Subject<Share|null>();
private subscriptions = new Subscription();
constructor(private http: HttpClient) {
constructor(private http: HttpClient, private shareSvc: ShareService) {
this.tgs$ = this.fetchAll.pipe(
switchMap((share) => this.getTalkgroups(share)),
shareReplay(),
@ -40,10 +42,17 @@ export class TalkgroupService {
switchMap(() => this.getAllTags()),
shareReplay(),
);
let sh = this.shareSvc.inShare();
console.log(sh);
if (sh) {
this.shareSvc.getShare(sh).subscribe(this.fetchAll);
} else {
this.fetchAll.next(null);
}
this.fillTgMap();
}
setShare(share: Share) {
setShare(share: Share|null) {
this.fetchAll.next(share);
}