diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index c8d407a..eafb531 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -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) } -} \ No newline at end of file +}