From 0471f2424db7b6aff463cb38eab6e0ac35bbb075 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 10 Dec 2017 22:25:59 +0000 Subject: [PATCH] Change the contact colour coding to be based on the uid. --- src/AddressBook.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/AddressBook.tsx b/src/AddressBook.tsx index 35c287f..fe42ce5 100644 --- a/src/AddressBook.tsx +++ b/src/AddressBook.tsx @@ -26,7 +26,7 @@ class AddressBook extends React.Component { } }); - function nameToColor(name: string) { + function getContactColor(contact: ContactType) { const colorOptions = [ colors.red500, colors.pink500, @@ -47,8 +47,9 @@ class AddressBook extends React.Component { ]; let sum = 0; - for (let i = 0 ; i < name.length ; i++) { - sum += name.charCodeAt(i); + const uid = contact.uid; + for (let i = 0 ; i < uid.length ; i++) { + sum += uid.charCodeAt(i); } return colorOptions[sum % colorOptions.length]; @@ -61,7 +62,7 @@ class AddressBook extends React.Component { let itemProps: any = { leftAvatar: ( {name[0].toUpperCase()}