Browse Source

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.
pull/142/head
Matthew Raymer 5 days ago
parent
commit
fd7d7f706c
  1. 6
      src/libs/crypto/vc/index.ts
  2. 28
      src/views/ContactsView.vue

6
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";

28
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<string> {
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,
};
}
}

Loading…
Cancel
Save