forked from jsnbuchanan/crowd-funder-for-time-pwa
Fix contact methods JSON string/array duality in PlatformServiceMixin
- Add ContactMaybeWithJsonStrings type usage for internal database operations - Implement $normalizeContacts() method to handle both JSON string and array formats - Update $contacts(), $getContact(), and $getAllContacts() to use normalization - Fix $updateContact() to properly convert contactMethods arrays to JSON strings - Add validation to filter out malformed contact method objects - Update ContactEditView to handle malformed data gracefully Resolves issue where contactMethods could be stored as JSON strings in database but expected as arrays in components, causing "Cannot create property 'label' on number '0'" errors.
This commit is contained in:
@@ -239,7 +239,21 @@ export default class ContactEditView extends Vue {
|
||||
this.contact = contact;
|
||||
this.contactName = contact.name || "";
|
||||
this.contactNotes = contact.notes || "";
|
||||
this.contactMethods = contact.contactMethods || [];
|
||||
|
||||
// Ensure contactMethods is a valid array of ContactMethod objects
|
||||
if (Array.isArray(contact.contactMethods)) {
|
||||
this.contactMethods = contact.contactMethods.filter((method) => {
|
||||
return (
|
||||
method &&
|
||||
typeof method === "object" &&
|
||||
typeof method.label === "string" &&
|
||||
typeof method.type === "string" &&
|
||||
typeof method.value === "string"
|
||||
);
|
||||
});
|
||||
} else {
|
||||
this.contactMethods = [];
|
||||
}
|
||||
} else {
|
||||
this.notify.error(
|
||||
`${NOTIFY_CONTACT_NOT_FOUND.message} ${contactDid}`,
|
||||
|
||||
Reference in New Issue
Block a user