diff --git a/src/app/components/contacts/contact-detail/contact-detail.component.html b/src/app/components/contacts/contact-detail/contact-detail.component.html
index 6c15fd2..c2a6bd4 100644
--- a/src/app/components/contacts/contact-detail/contact-detail.component.html
+++ b/src/app/components/contacts/contact-detail/contact-detail.component.html
@@ -10,11 +10,13 @@
+
+
@if (selectedUser && selectedUserId) {
- } @if (isMobileNavbarOpen) {
+ } @if (showMobileNavbar) {
}
+
+
();
+ @Output() contactClosed = new EventEmitter();
- isLoading: boolean = false;
selectedUser: User | null = null;
- isMobileNavbarOpen: boolean = false;
+ isLoading = false;
+ showMobileNavbar = false;
showConfirmDialog = false;
constructor(
@@ -41,11 +41,15 @@ export class ContactDetailComponent {
private updateNotifierService: UpdateNotifierService
) {}
- ngOnChanges(changes: SimpleChanges) {
- if (
- changes['selectedUserId'] !== undefined &&
- changes['selectedUserId'].currentValue !== ''
- ) {
+ /**
+ * If the `selectedUserId` input property changes and has a current value,
+ * it loads the user data. Otherwise, it resets the `selectedUser` to null.
+ *
+ * @param changes An object of key-value pairs representing the changed properties.
+ */
+
+ ngOnChanges(changes: SimpleChanges): void {
+ if (changes['selectedUserId']?.currentValue) {
this.loadUser();
} else {
this.selectedUser = null;
@@ -53,13 +57,56 @@ export class ContactDetailComponent {
}
/**
- * Closes the contact details view by resetting the current user id in the
- * shared service and emitting the closeContactEmitter event.
+ * Emits an event with the value false to trigger the contact list to close.
*/
- closeUserDetails() {
- this.closeContactEmitter.emit();
+ emitCloseContact() {
+ this.contactClosed.emit(false);
}
+ /**
+ * Toggles the visibility of the mobile contact details navbar.
+ */
+ toggleNav(): void {
+ this.showMobileNavbar = !this.showMobileNavbar;
+ }
+
+ /**
+ * Toggles the visibility of the confirmation dialog.
+ * This method switches the `showConfirmDialog` boolean state.
+ */
+ toggleConfirmDialog(): void {
+ this.showConfirmDialog = !this.showConfirmDialog;
+ }
+
+ /**
+ * Sets the overlay data for the contact overlay to the given user data,
+ * and hides the mobile contact details navbar.
+ *
+ * @param userData The user data to be edited.
+ */
+ editContact(userData: User) {
+ this.overlayService.setOverlayData('contactOverlay', userData);
+ this.showMobileNavbar = false;
+ }
+
+ /**
+ * Deletes the contact with the given id, shows a success toast, triggers an update of the contact list,
+ * and closes the contact details component.
+ */
+ async deleteContact() {
+ try {
+ await lastValueFrom(this.apiService.deleteUserById(this.selectedUserId!));
+ this.toastNotificationService.deleteContactSuccessToast();
+ this.updateNotifierService.notifyUpdate('contact');
+ this.emitCloseContact();
+ } catch (error) {
+ console.error(error);
+ }
+ }
+
+ /**
+ * Loads the user data with the given id and sets it to the `selectedUser` property.
+ */
loadUser(): void {
this.isLoading = true;
@@ -80,37 +127,4 @@ export class ContactDetailComponent {
},
});
}
-
- /**
- * Toggles the mobile navigation bar on and off.
- * @remarks This method is used by the contact details component to toggle
- * the mobile navigation bar when the user clicks the three points icon.
- */
- toggleNav() {
- this.isMobileNavbarOpen = !this.isMobileNavbarOpen;
- }
-
- /**
- * Opens the edit contact dialog by setting the appropriate flags in the shared service.
- * This method is used by the contact details component to open the edit contact dialog when the user clicks the edit button.
- */
- editContact(userData: User) {
- this.overlayService.setOverlayData('contactOverlay', userData);
- this.isMobileNavbarOpen = false;
- }
-
- toggleConfirmDialog() {
- this.showConfirmDialog = !this.showConfirmDialog;
- }
-
- async deleteContact() {
- try {
- await lastValueFrom(this.apiService.deleteUserById(this.selectedUserId!));
- this.toastNotificationService.deleteContactSuccessToast();
- this.updateNotifierService.notifyUpdate('contact');
- this.closeUserDetails();
- } catch (error) {
- console.error(error);
- }
- }
}
diff --git a/src/app/components/contacts/contacts.component.html b/src/app/components/contacts/contacts.component.html
index 8025ab4..98fe9b2 100644
--- a/src/app/components/contacts/contacts.component.html
+++ b/src/app/components/contacts/contacts.component.html
@@ -71,7 +71,7 @@
}"
[selectedUserId]="selectedUserId"
[currentUser]="currentUser"
- (closeContactEmitter)="closeContactEmitter()"
+ (contactClosed)="handleCloseContact()"
>
diff --git a/src/app/components/contacts/contacts.component.ts b/src/app/components/contacts/contacts.component.ts
index 480a37d..25528a3 100644
--- a/src/app/components/contacts/contacts.component.ts
+++ b/src/app/components/contacts/contacts.component.ts
@@ -97,7 +97,7 @@ export class ContactsComponent {
/**
* Triggers the resize function to adjust UI elements based on the current state.
*/
- closeContactEmitter() {
+ handleCloseContact() {
this.selectedUserId = null;
this.onResize();
}
diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json
index 3005c79..9fbeca7 100644
--- a/src/assets/i18n/de.json
+++ b/src/assets/i18n/de.json
@@ -170,7 +170,8 @@
"contactPhone": "Telefon",
"contactPhoneTxT": "Keine Telefonnummer",
"contactLastOnline": "Zuletzt online gesehen",
- "contactLastOnlineTxt": "Derzeit online",
+ "contactCurrentlyOnline": "Derzeit online",
+ "contactNeverSeenOnline": "Niemals online gesehen",
"addContact": "Kontakt hinzufügen",
"editContact": "Kontakt bearbeiten",
"firstName": "Vorname",
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index 9ef27d1..9b8e566 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -170,7 +170,8 @@
"contactPhone": "Phone",
"contactPhoneTxT": "No phone number",
"contactLastOnline": "Last seen online",
- "contactLastOnlineTxt": "Currently online",
+ "contactCurrentlyOnline": "Currently online",
+ "contactNeverSeenOnline": "Never seen online",
"editContact": "Edit contact",
"addContact": "Add contact",
"firstName": "First name",