diff --git a/src/src/app/components/trip/trip.component.ts b/src/src/app/components/trip/trip.component.ts index 33bcde8..356aa79 100644 --- a/src/src/app/components/trip/trip.component.ts +++ b/src/src/app/components/trip/trip.component.ts @@ -2026,10 +2026,15 @@ export class TripComponent implements AfterViewInit { .subscribe({ next: () => { this.trip!.attachments = this.trip?.attachments?.filter((att) => att.id != attachmentId); - if (this.selectedItem?.attachments?.length) { - if (this.selectedItem.attachments.some((a) => a.id == attachmentId)) - this.selectedItem.attachments = this.selectedItem.attachments.filter((a) => a.id != attachmentId); - } + let modifiedItem = false; + this.trip?.days.forEach(d => d.items.forEach(i => { + if (i.attachments?.length) { + i.attachments = i.attachments.filter(attachment => attachment.id != attachmentId); + modifiedItem = true; + } + })) + if (this.selectedItem?.attachments?.length) this.selectedItem.attachments = this.selectedItem.attachments.filter((a) => a.id != attachmentId); + if (modifiedItem) this.flattenTripDayItems(); }, }); }