Fix multiple requests on trip sharing

This commit is contained in:
itskovacs 2025-08-13 22:07:00 +02:00
parent abe545c094
commit 0aee97995e

View File

@ -32,6 +32,7 @@ import {
combineLatest, combineLatest,
forkJoin, forkJoin,
Observable, Observable,
of,
switchMap, switchMap,
take, take,
tap, tap,
@ -1082,7 +1083,9 @@ export class TripComponent implements AfterViewInit {
this.apiService.postTripDayItem(item, this.trip!.id!, item.day_id), this.apiService.postTripDayItem(item, this.trip!.id!, item.day_id),
); );
forkJoin(obs$).subscribe({ forkJoin(obs$)
.pipe(take(1))
.subscribe({
next: (items: TripItem[]) => { next: (items: TripItem[]) => {
const index = this.trip!.days.findIndex((d) => d.id == day_id); const index = this.trip!.days.findIndex((d) => d.id == day_id);
if (index === -1) return; if (index === -1) return;
@ -1210,8 +1213,9 @@ export class TripComponent implements AfterViewInit {
.createSharedTrip(this.trip?.id!) .createSharedTrip(this.trip?.id!)
.pipe(take(1)) .pipe(take(1))
.subscribe({ .subscribe({
next: () => { next: (url) => {
this.trip!.shared = true; this.trip!.shared = true;
this.tripSharedURL$ = of(url);
}, },
}); });
} }