Saving Messages

This commit is contained in:
Sarah Jamie Lewis 2018-11-28 12:34:49 -08:00
parent b5875453fb
commit 7a8e102b2a
1 changed files with 9 additions and 8 deletions

View File

@ -1,19 +1,19 @@
package gothings
import (
"bounce/go/constants"
"bounce/go/gobjects"
"bounce/go/the"
"cwtch.im/cwtch/model"
"encoding/base32"
"strings"
"log"
"bounce/go/constants"
"bounce/go/the"
"bounce/go/gobjects"
"strings"
)
type InterfaceState struct {
parentGcd *GrandCentralDispatcher
contacts map[string]*gobjects.Contact
messages map[string][]*gobjects.Message
contacts map[string]*gobjects.Contact
messages map[string][]*gobjects.Message
}
func NewUIState(gcd *GrandCentralDispatcher) (uis InterfaceState) {
@ -39,7 +39,7 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) {
if the.Peer.GetContact(c.Handle) == nil {
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(c.Handle))
pp := &model.PublicProfile{Name: c.DisplayName, Ed25519PublicKey: decodedPub[:32], Trusted: c.Trusted, Blocked:false, Onion:c.Handle, Attributes:make(map[string]string)}
pp := &model.PublicProfile{Name: c.DisplayName, Ed25519PublicKey: decodedPub[:32], Trusted: c.Trusted, Blocked: false, Onion: c.Handle, Attributes: make(map[string]string)}
pp.SetAttribute("name", c.DisplayName)
the.Peer.GetProfile().Contacts[c.Handle] = pp
if c.Trusted {
@ -98,6 +98,7 @@ func (this *InterfaceState) AddMessage(m *gobjects.Message) {
c.Badge++
this.UpdateContact(c.Handle)
}
the.CwtchApp.SaveProfile(the.Peer)
}
func (this *InterfaceState) GetMessages(handle string) []*gobjects.Message {
@ -113,4 +114,4 @@ func (this *InterfaceState) UpdateContact(handle string) {
if found {
this.parentGcd.UpdateContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
}
}
}