diff --git a/src/app/components/contacts/contacts.component.ts b/src/app/components/contacts/contacts.component.ts index 82e7a0c..6e90989 100644 --- a/src/app/components/contacts/contacts.component.ts +++ b/src/app/components/contacts/contacts.component.ts @@ -61,7 +61,8 @@ export class ContactsComponent { private subscribeToUserUpdates() { this.updateNotifierService.contactUpdated$ .pipe(takeUntil(this.destroy$)) - .subscribe(() => { + .subscribe((userId: string) => { + this.selectedUserId = userId; this.loadAllUsers(); }); } diff --git a/src/app/services/update-notifier.service.ts b/src/app/services/update-notifier.service.ts index 6f2fc99..f2a4529 100644 --- a/src/app/services/update-notifier.service.ts +++ b/src/app/services/update-notifier.service.ts @@ -5,15 +5,15 @@ import { Subject } from 'rxjs'; providedIn: 'root', }) export class UpdateNotifierService { - private updateSubjects: Record> = { - task: new Subject(), - contact: new Subject(), + private updateSubjects: Record> = { + task: new Subject(), + contact: new Subject(), }; taskUpdated$ = this.updateSubjects['task'].asObservable(); contactUpdated$ = this.updateSubjects['contact'].asObservable(); - notifyUpdate(type: 'task' | 'contact') { - this.updateSubjects[type].next(); + notifyUpdate(type: 'task' | 'contact', payload?: string) { + this.updateSubjects[type].next(payload ?? ''); } } diff --git a/src/app/shared/components/overlay/contact-overlay/contact-form/contact-form.component.ts b/src/app/shared/components/overlay/contact-overlay/contact-form/contact-form.component.ts index 4a7771c..07596d8 100644 --- a/src/app/shared/components/overlay/contact-overlay/contact-form/contact-form.component.ts +++ b/src/app/shared/components/overlay/contact-overlay/contact-form/contact-form.component.ts @@ -242,9 +242,11 @@ export class ContactFormComponent implements OnInit, OnChanges { }; const snakeCaseUserData = this.convertCamelToSnake(userData); - await lastValueFrom(this.apiService.saveNewUser(snakeCaseUserData)); + const savedUser = await lastValueFrom( + this.apiService.saveNewUser(snakeCaseUserData) + ); this.toastNotificationService.createContactSuccessToast(); - this.updateNotifierService.notifyUpdate('contact'); + this.updateNotifierService.notifyUpdate('contact', savedUser.id); this.closeDialog(); } catch (error) { console.error('Fehler beim Speichern des Kontakts:', error);