From b54f25eee953eb2b0ff3ad355453dfeaf0dd806a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 4 Jan 2020 23:16:34 +0200 Subject: [PATCH] Handle contacts with null for a uid. It seems like we aren't setting a uid for contacts without one when importing so it's possible to get ones without a uid. Opened ticket #71 to track this issue. --- src/components/AddressBook.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/AddressBook.tsx b/src/components/AddressBook.tsx index 6a9e4cb..4da0b31 100644 --- a/src/components/AddressBook.tsx +++ b/src/components/AddressBook.tsx @@ -29,6 +29,12 @@ function getContactColor(contact: ContactType) { colors.deepOrange[500], ]; + if (!contact.uid) { + console.error(`Contact uid is null for contact ${contact.fn}`); + console.error(contact.toIcal()); + return colorOptions[0]; + } + let sum = 0; const uid = contact.uid; for (let i = 0 ; i < uid.length ; i++) {