forked from jsnbuchanan/crowd-funder-for-time-pwa
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.
This commit is contained in:
@@ -16,11 +16,11 @@ const u8a = {
|
|||||||
toString: (bytes: Uint8Array, encoding: string): string => {
|
toString: (bytes: Uint8Array, encoding: string): string => {
|
||||||
if (encoding === "base16") {
|
if (encoding === "base16") {
|
||||||
return Array.from(bytes)
|
return Array.from(bytes)
|
||||||
.map(b => b.toString(16).padStart(2, '0'))
|
.map((b) => b.toString(16).padStart(2, "0"))
|
||||||
.join('');
|
.join("");
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported encoding: ${encoding}`);
|
throw new Error(`Unsupported encoding: ${encoding}`);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
import { didEthLocalResolver } from "./did-eth-local-resolver";
|
import { didEthLocalResolver } from "./did-eth-local-resolver";
|
||||||
|
|||||||
@@ -770,8 +770,8 @@ export default class ContactsView extends Vue {
|
|||||||
// Update local contacts list
|
// Update local contacts list
|
||||||
this.updateContactsList(newContact);
|
this.updateContactsList(newContact);
|
||||||
|
|
||||||
// Set visibility and get success message
|
// Set visibility and get success notification data
|
||||||
const addedMessage = await this.handleContactVisibility(newContact);
|
const notificationData = await this.handleContactVisibility(newContact);
|
||||||
|
|
||||||
// Clear input field
|
// Clear input field
|
||||||
this.contactInput = "";
|
this.contactInput = "";
|
||||||
@@ -779,8 +779,12 @@ export default class ContactsView extends Vue {
|
|||||||
// Handle registration prompt if needed
|
// Handle registration prompt if needed
|
||||||
await this.handleRegistrationPrompt(newContact);
|
await this.handleRegistrationPrompt(newContact);
|
||||||
|
|
||||||
// Show success notification
|
// Show success notification with custom title and message
|
||||||
this.notify.success(addedMessage);
|
this.notify.toast(
|
||||||
|
notificationData.title,
|
||||||
|
notificationData.message,
|
||||||
|
TIMEOUTS.STANDARD,
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.handleContactAddError(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) {
|
if (this.activeDid) {
|
||||||
await this.setVisibility(newContact, true, false);
|
await this.setVisibility(newContact, true, false);
|
||||||
newContact.seesMe = true;
|
newContact.seesMe = true;
|
||||||
return NOTIFY_CONTACTS_ADDED_VISIBLE.message;
|
return {
|
||||||
|
title: NOTIFY_CONTACTS_ADDED_VISIBLE.title,
|
||||||
|
message: NOTIFY_CONTACTS_ADDED_VISIBLE.message,
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return NOTIFY_CONTACTS_ADDED.message;
|
return {
|
||||||
|
title: NOTIFY_CONTACTS_ADDED.title,
|
||||||
|
message: NOTIFY_CONTACTS_ADDED.message,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user