diff --git a/go/characters/presencepoller.go b/go/characters/presencepoller.go index 87d4f08..87bfafa 100644 --- a/go/characters/presencepoller.go +++ b/go/characters/presencepoller.go @@ -1,6 +1,7 @@ package characters import ( + "cwtch.im/cwtch/event" "cwtch.im/ui/go/cwutil" "cwtch.im/ui/go/gobjects" "cwtch.im/ui/go/the" @@ -26,7 +27,7 @@ func PresencePoller(getContact func(string) *gobjects.Contact, addContact func(c c.Trusted, }) c.SetAttribute("name", c.Name) - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) } cxnState, found := the.Peer.GetPeers()[contacts[i]] diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index 965ce0e..5f87c74 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -1,6 +1,7 @@ package gothings import ( + "cwtch.im/cwtch/event" "cwtch.im/ui/go/constants" "cwtch.im/ui/go/cwutil" @@ -68,7 +69,7 @@ func (this *GrandCentralDispatcher) sendMessage(message string, mID uint) { if len(this.CurrentOpenConversation()) == 32 { // SEND TO GROUP if !the.Peer.GetGroup(this.CurrentOpenConversation()).Accepted { the.Peer.GetGroup(this.CurrentOpenConversation()).Accepted = true - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) c := this.UIState.GetContact(this.CurrentOpenConversation()) c.Trusted = true this.UIState.UpdateContact(c.Handle) @@ -121,7 +122,7 @@ func (this *GrandCentralDispatcher) loadMessagesPane(handle string) { } var name string var exists bool - name, exists = the.Peer.GetProfile().GetCustomAttribute(tl[i].PeerID + "_name") + name, exists = the.Peer.GetProfile().GetAttribute(tl[i].PeerID + "_name") if !exists || name == "" { name = tl[i].PeerID[:16] + "..." } @@ -210,7 +211,7 @@ func (this *GrandCentralDispatcher) importString(str string) { } the.Peer.JoinServer(group.GroupServer) - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) this.UIState.AddContact(&gobjects.Contact{ groupID, groupID[:12], @@ -258,13 +259,13 @@ func (this *GrandCentralDispatcher) importString(str string) { return } - _, exists := the.Peer.GetProfile().GetCustomAttribute(name + "_onion") + _, exists := the.Peer.GetProfile().GetAttribute(name + "_onion") if exists { this.InvokePopup("can't re-use names :(") return } - _, exists = the.Peer.GetProfile().GetCustomAttribute(onion + "_name") + _, exists = the.Peer.GetProfile().GetAttribute(onion + "_name") if exists { this.InvokePopup("already have this contact") return //TODO: bring them to the duplicate @@ -284,7 +285,7 @@ func (this *GrandCentralDispatcher) popup(str string) { func (this *GrandCentralDispatcher) updateNick(nick string) { the.Peer.GetProfile().Name = nick - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) } func (this *GrandCentralDispatcher) createGroup(server, groupName string) { @@ -304,7 +305,7 @@ func (this *GrandCentralDispatcher) createGroup(server, groupName string) { group := the.Peer.GetGroup(groupID) group.SetAttribute("nick", groupName) - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) the.Peer.JoinServer(server) group.NewMessage = make(chan model.Message) diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index d280bcc..dab29b6 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -1,6 +1,7 @@ package gothings import ( + "cwtch.im/cwtch/event" "cwtch.im/cwtch/model" "cwtch.im/ui/go/constants" "cwtch.im/ui/go/gobjects" @@ -45,7 +46,7 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) { if c.Trusted { the.Peer.GetProfile().TrustPeer(c.Handle) } - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) go the.Peer.PeerWithOnion(c.Handle) } @@ -54,7 +55,7 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) { this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted) } - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) } func (this *InterfaceState) GetContact(handle string) *gobjects.Contact { @@ -98,7 +99,7 @@ func (this *InterfaceState) AddMessage(m *gobjects.Message) { c.Badge++ this.UpdateContact(c.Handle) } - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) } func (this *InterfaceState) GetMessages(handle string) []*gobjects.Message { diff --git a/main.go b/main.go index b810ff9..c37e2bc 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( libapp "cwtch.im/cwtch/app" + "cwtch.im/cwtch/event" "cwtch.im/cwtch/model" "cwtch.im/ui/go/characters" "cwtch.im/ui/go/cwutil" @@ -126,7 +127,7 @@ func loadCwtchData(gcd *gothings.GrandCentralDispatcher) { log.Errorf("couldn't create one. is your cwtch folder writable?") os.Exit(1) } - the.CwtchApp.SaveProfile(the.Peer) + the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{})) } else { the.Peer = the.CwtchApp.PrimaryIdentity() }