fix race conditions for contact access #189
|
@ -18,7 +18,6 @@ func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) {
|
||||||
the.EventBus.Subscribe(event.NewGroupInvite, q.EventChannel)
|
the.EventBus.Subscribe(event.NewGroupInvite, q.EventChannel)
|
||||||
the.EventBus.Subscribe(event.SendMessageToGroupError, q.EventChannel)
|
the.EventBus.Subscribe(event.SendMessageToGroupError, q.EventChannel)
|
||||||
the.EventBus.Subscribe(event.SendMessageToPeerError, q.EventChannel)
|
the.EventBus.Subscribe(event.SendMessageToPeerError, q.EventChannel)
|
||||||
the.EventBus.Subscribe(event.JoinServer, q.EventChannel)
|
|
||||||
the.EventBus.Subscribe(event.ServerStateChange, q.EventChannel)
|
the.EventBus.Subscribe(event.ServerStateChange, q.EventChannel)
|
||||||
the.EventBus.Subscribe(event.PeerStateChange, q.EventChannel)
|
the.EventBus.Subscribe(event.PeerStateChange, q.EventChannel)
|
||||||
subscribed <- true
|
subscribed <- true
|
||||||
|
|
|
@ -50,9 +50,13 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
||||||
if len(handle) == 32 {
|
if len(handle) == 32 {
|
||||||
group := the.Peer.GetGroup(handle)
|
group := the.Peer.GetGroup(handle)
|
||||||
if group != nil {
|
if group != nil {
|
||||||
|
nick, exists := group.GetAttribute("nick")
|
||||||
|
if !exists {
|
||||||
|
nick = group.GroupID[:12]
|
||||||
|
}
|
||||||
this.AddContact(&gobjects.Contact{
|
this.AddContact(&gobjects.Contact{
|
||||||
handle,
|
handle,
|
||||||
handle,
|
nick,
|
||||||
cwutil.RandomGroupImage(handle),
|
cwutil.RandomGroupImage(handle),
|
||||||
group.GroupServer,
|
group.GroupServer,
|
||||||
0,
|
0,
|
||||||
|
@ -68,9 +72,13 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
||||||
} else {
|
} else {
|
||||||
contact := the.Peer.GetContact(handle)
|
contact := the.Peer.GetContact(handle)
|
||||||
if contact != nil && handle != contact.Onion {
|
if contact != nil && handle != contact.Onion {
|
||||||
|
nick, exists := contact.GetAttribute("name")
|
||||||
|
if !exists {
|
||||||
|
nick = contact.Onion
|
||||||
|
}
|
||||||
this.AddContact(&gobjects.Contact{
|
this.AddContact(&gobjects.Contact{
|
||||||
handle,
|
handle,
|
||||||
handle,
|
nick,
|
||||||
cwutil.RandomProfileImage(handle),
|
cwutil.RandomProfileImage(handle),
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
|
|
Reference in New Issue