sort and update contact list #23

Merged
sarah merged 2 commits from clsort into trunk 2021-04-13 21:01:24 +00:00
2 changed files with 13 additions and 1 deletions

View File

@ -9,4 +9,5 @@ type Contact struct {
SaveHistory string `json:"saveConversationHistory"`
Messages int `json:"numMessages"`
Unread int `json:"numUnread"`
LastMessage string `json:"lastMsgTime"`
}

View File

@ -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)