diff --git a/utils/contacts.go b/utils/contacts.go index c93ff22..fc1b57a 100644 --- a/utils/contacts.go +++ b/utils/contacts.go @@ -9,4 +9,5 @@ type Contact struct { SaveHistory string `json:"saveConversationHistory"` Messages int `json:"numMessages"` Unread int `json:"numUnread"` + LastMessage string `json:"lastMsgTime"` } diff --git a/utils/eventHandler.go b/utils/eventHandler.go index cd7a60b..a9fc0a1 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -10,6 +10,7 @@ import ( "git.openprivacy.ca/flutter/libcwtch-go/constants" "git.openprivacy.ca/flutter/libcwtch-go/features/groups" "git.openprivacy.ca/openprivacy/log" + "strconv" ) import "cwtch.im/cwtch/event" @@ -122,7 +123,17 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string { if !set { saveHistory = event.DeleteHistoryDefault } - contacts = append(contacts, Contact{Name: name, Onion: contactInfo.Onion, Status: contactInfo.State, Picture: cpicPath, Authorization: string(contactInfo.Authorization), SaveHistory: saveHistory, Messages: contactInfo.Timeline.Len(), Unread: 0}) + contacts = append(contacts, Contact{ + Name: name, + Onion: contactInfo.Onion, + Status: contactInfo.State, + Picture: cpicPath, + Authorization: string(contactInfo.Authorization), + SaveHistory: saveHistory, + Messages: contactInfo.Timeline.Len(), + Unread: 0, + LastMessage: strconv.Itoa(getLastMessageTime(&contactInfo.Timeline)), + }) } bytes, _ := json.Marshal(contacts)