⚡ Fix multiple requests on trip sharing
This commit is contained in:
parent
abe545c094
commit
0aee97995e
@ -32,6 +32,7 @@ import {
|
|||||||
combineLatest,
|
combineLatest,
|
||||||
forkJoin,
|
forkJoin,
|
||||||
Observable,
|
Observable,
|
||||||
|
of,
|
||||||
switchMap,
|
switchMap,
|
||||||
take,
|
take,
|
||||||
tap,
|
tap,
|
||||||
@ -1082,16 +1083,18 @@ 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$)
|
||||||
next: (items: TripItem[]) => {
|
.pipe(take(1))
|
||||||
const index = this.trip!.days.findIndex((d) => d.id == day_id);
|
.subscribe({
|
||||||
if (index === -1) return;
|
next: (items: TripItem[]) => {
|
||||||
|
const index = this.trip!.days.findIndex((d) => d.id == day_id);
|
||||||
|
if (index === -1) return;
|
||||||
|
|
||||||
const td: TripDay = this.trip!.days[index]!;
|
const td: TripDay = this.trip!.days[index]!;
|
||||||
td.items.push(...items);
|
td.items.push(...items);
|
||||||
this.flattenTripDayItems();
|
this.flattenTripDayItems();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -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);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user