From fd7d7f706cdc3132e8d420d89b4df493d08392b2 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 21 Jul 2025 12:25:29 +0000 Subject: [PATCH] Enhance handleContactVisibility to return both title and message Modified handleContactVisibility method to return structured notification data with both title and message properties instead of just a string message. Updated addContact method to use notify.toast() with custom title and message from notification constants, providing more specific user feedback when contacts are added with or without visibility settings. --- src/libs/crypto/vc/index.ts | 6 +++--- src/views/ContactsView.vue | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/libs/crypto/vc/index.ts b/src/libs/crypto/vc/index.ts index 3aca7c59..a208885d 100644 --- a/src/libs/crypto/vc/index.ts +++ b/src/libs/crypto/vc/index.ts @@ -16,11 +16,11 @@ const u8a = { toString: (bytes: Uint8Array, encoding: string): string => { if (encoding === "base16") { return Array.from(bytes) - .map(b => b.toString(16).padStart(2, '0')) - .join(''); + .map((b) => b.toString(16).padStart(2, "0")) + .join(""); } throw new Error(`Unsupported encoding: ${encoding}`); - } + }, }; import { didEthLocalResolver } from "./did-eth-local-resolver"; diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 2066e07e..c1c87e97 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -770,8 +770,8 @@ export default class ContactsView extends Vue { // Update local contacts list this.updateContactsList(newContact); - // Set visibility and get success message - const addedMessage = await this.handleContactVisibility(newContact); + // Set visibility and get success notification data + const notificationData = await this.handleContactVisibility(newContact); // Clear input field this.contactInput = ""; @@ -779,8 +779,12 @@ export default class ContactsView extends Vue { // Handle registration prompt if needed await this.handleRegistrationPrompt(newContact); - // Show success notification - this.notify.success(addedMessage); + // Show success notification with custom title and message + this.notify.toast( + notificationData.title, + notificationData.message, + TIMEOUTS.STANDARD, + ); } catch (err) { this.handleContactAddError(err); } @@ -813,15 +817,23 @@ export default class ContactsView extends Vue { } /** - * Handle contact visibility settings and return appropriate message + * Handle contact visibility settings and return appropriate notification data */ - private async handleContactVisibility(newContact: Contact): Promise { + private async handleContactVisibility( + newContact: Contact, + ): Promise<{ title: string; message: string }> { if (this.activeDid) { await this.setVisibility(newContact, true, false); newContact.seesMe = true; - return NOTIFY_CONTACTS_ADDED_VISIBLE.message; + return { + title: NOTIFY_CONTACTS_ADDED_VISIBLE.title, + message: NOTIFY_CONTACTS_ADDED_VISIBLE.message, + }; } else { - return NOTIFY_CONTACTS_ADDED.message; + return { + title: NOTIFY_CONTACTS_ADDED.title, + message: NOTIFY_CONTACTS_ADDED.message, + }; } }