From e439c0954b1eb68b2ce8a2aa138052ef737bd691 Mon Sep 17 00:00:00 2001 From: erinn Date: Wed, 17 Mar 2021 15:42:09 -0700 Subject: [PATCH] initialize message counter --- utils/contacts.go | 10 ++++++---- utils/eventHandler.go | 9 ++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/utils/contacts.go b/utils/contacts.go index ddd1f9a..c1f1467 100644 --- a/utils/contacts.go +++ b/utils/contacts.go @@ -1,8 +1,10 @@ package utils type Contact struct { - Name string `json:"name"` - Onion string `json:"onion"` - Status string `json:"status"` - Picture string `json:"picture"` + Name string `json:"name"` + Onion string `json:"onion"` + Status string `json:"status"` + Picture string `json:"picture"` + Messages int `json:"numMessages"` + Unread int `json:"numUnread"` } diff --git a/utils/eventHandler.go b/utils/eventHandler.go index 45d0318..7c365f9 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -106,7 +106,14 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string { } cpicPath := GetPicturePath(cpic) contactInfo := profile.GetContact(contact) - contacts = append(contacts, Contact{Name: contactInfo.Name, Onion: contactInfo.Onion, Status: contactInfo.State, Picture: cpicPath}) + contacts = append(contacts, Contact{ + Name: contactInfo.Name, + Onion: contactInfo.Onion, + Status: contactInfo.State, + Picture: cpicPath, + Messages: contactInfo.Timeline.Len(), + Unread: 0, + }) } bytes, _ := json.Marshal(contacts)