forked from cwtch.im/ui
add storage eventbus calls
This commit is contained in:
parent
e620d48bc8
commit
f667c1ec70
|
@ -26,8 +26,12 @@ func PresencePoller(getContact func(string) *gobjects.Contact, addContact func(c
|
||||||
0,
|
0,
|
||||||
c.Trusted,
|
c.Trusted,
|
||||||
})
|
})
|
||||||
c.SetAttribute("name", c.Name)
|
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
the.CwtchApp.EventBus().Publish(event.NewEvent(event.SetPeerAttribute, map[event.Field]string{
|
||||||
|
event.RemotePeer: contacts[i],
|
||||||
|
event.Key: "name",
|
||||||
|
event.Data: c.Name,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
cxnState, found := the.Peer.GetPeers()[contacts[i]]
|
cxnState, found := the.Peer.GetPeers()[contacts[i]]
|
||||||
|
|
|
@ -68,8 +68,11 @@ func (this *GrandCentralDispatcher) sendMessage(message string, mID uint) {
|
||||||
|
|
||||||
if len(this.CurrentOpenConversation()) == 32 { // SEND TO GROUP
|
if len(this.CurrentOpenConversation()) == 32 { // SEND TO GROUP
|
||||||
if !the.Peer.GetGroup(this.CurrentOpenConversation()).Accepted {
|
if !the.Peer.GetGroup(this.CurrentOpenConversation()).Accepted {
|
||||||
the.Peer.GetGroup(this.CurrentOpenConversation()).Accepted = true
|
err := the.Peer.AcceptInvite(this.CurrentOpenConversation())
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
if err != nil {
|
||||||
|
log.Errorf("tried to mark a nonexistent group as existed. bad!")
|
||||||
|
return
|
||||||
|
}
|
||||||
c := this.UIState.GetContact(this.CurrentOpenConversation())
|
c := this.UIState.GetContact(this.CurrentOpenConversation())
|
||||||
c.Trusted = true
|
c.Trusted = true
|
||||||
this.UIState.UpdateContact(c.Handle)
|
this.UIState.UpdateContact(c.Handle)
|
||||||
|
@ -211,7 +214,6 @@ func (this *GrandCentralDispatcher) importString(str string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
the.Peer.JoinServer(group.GroupServer)
|
the.Peer.JoinServer(group.GroupServer)
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
|
||||||
this.UIState.AddContact(&gobjects.Contact{
|
this.UIState.AddContact(&gobjects.Contact{
|
||||||
groupID,
|
groupID,
|
||||||
groupID[:12],
|
groupID[:12],
|
||||||
|
@ -285,7 +287,9 @@ func (this *GrandCentralDispatcher) popup(str string) {
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) updateNick(nick string) {
|
func (this *GrandCentralDispatcher) updateNick(nick string) {
|
||||||
the.Peer.GetProfile().Name = nick
|
the.Peer.GetProfile().Name = nick
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
the.CwtchApp.EventBus().Publish(event.NewEvent(event.SetProfileName, map[event.Field]string{
|
||||||
|
event.ProfileName: nick,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) createGroup(server, groupName string) {
|
func (this *GrandCentralDispatcher) createGroup(server, groupName string) {
|
||||||
|
@ -304,8 +308,11 @@ func (this *GrandCentralDispatcher) createGroup(server, groupName string) {
|
||||||
})
|
})
|
||||||
|
|
||||||
group := the.Peer.GetGroup(groupID)
|
group := the.Peer.GetGroup(groupID)
|
||||||
group.SetAttribute("nick", groupName)
|
the.CwtchApp.EventBus().Publish(event.NewEvent(event.SetGroupAttribute, map[event.Field]string{
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
event.GroupID: groupID,
|
||||||
|
event.Key: "nick",
|
||||||
|
event.Data: groupName,
|
||||||
|
}))
|
||||||
|
|
||||||
the.Peer.JoinServer(server)
|
the.Peer.JoinServer(server)
|
||||||
group.NewMessage = make(chan model.Message)
|
group.NewMessage = make(chan model.Message)
|
||||||
|
|
|
@ -46,7 +46,13 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) {
|
||||||
if c.Trusted {
|
if c.Trusted {
|
||||||
the.Peer.GetProfile().TrustPeer(c.Handle)
|
the.Peer.GetProfile().TrustPeer(c.Handle)
|
||||||
}
|
}
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
|
||||||
|
the.CwtchApp.EventBus().Publish(event.NewEvent(event.SetPeerAttribute, map[event.Field]string{
|
||||||
|
event.RemotePeer: c.Handle,
|
||||||
|
event.Key: "name",
|
||||||
|
event.Data: c.DisplayName,
|
||||||
|
}))
|
||||||
|
|
||||||
go the.Peer.PeerWithOnion(c.Handle)
|
go the.Peer.PeerWithOnion(c.Handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +60,6 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) {
|
||||||
this.contacts[c.Handle] = c
|
this.contacts[c.Handle] = c
|
||||||
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
|
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
|
||||||
}
|
}
|
||||||
|
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
||||||
|
@ -99,7 +103,6 @@ func (this *InterfaceState) AddMessage(m *gobjects.Message) {
|
||||||
c.Badge++
|
c.Badge++
|
||||||
this.UpdateContact(c.Handle)
|
this.UpdateContact(c.Handle)
|
||||||
}
|
}
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *InterfaceState) GetMessages(handle string) []*gobjects.Message {
|
func (this *InterfaceState) GetMessages(handle string) []*gobjects.Message {
|
||||||
|
|
2
main.go
2
main.go
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
libapp "cwtch.im/cwtch/app"
|
libapp "cwtch.im/cwtch/app"
|
||||||
"cwtch.im/cwtch/event"
|
|
||||||
"cwtch.im/cwtch/model"
|
"cwtch.im/cwtch/model"
|
||||||
"cwtch.im/ui/go/characters"
|
"cwtch.im/ui/go/characters"
|
||||||
"cwtch.im/ui/go/cwutil"
|
"cwtch.im/ui/go/cwutil"
|
||||||
|
@ -127,7 +126,6 @@ func loadCwtchData(gcd *gothings.GrandCentralDispatcher) {
|
||||||
log.Errorf("couldn't create one. is your cwtch folder writable?")
|
log.Errorf("couldn't create one. is your cwtch folder writable?")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
the.CwtchApp.EventBus().Publish(event.NewEvent(event.RequestProfileSave, map[event.Field]string{}))
|
|
||||||
} else {
|
} else {
|
||||||
the.Peer = the.CwtchApp.PrimaryIdentity()
|
the.Peer = the.CwtchApp.PrimaryIdentity()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue