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.SendMessageToGroupError, 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.PeerStateChange, q.EventChannel)
|
||||
subscribed <- true
|
||||
|
|
|
@ -50,9 +50,13 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
|||
if len(handle) == 32 {
|
||||
group := the.Peer.GetGroup(handle)
|
||||
if group != nil {
|
||||
nick, exists := group.GetAttribute("nick")
|
||||
if !exists {
|
||||
nick = group.GroupID[:12]
|
||||
}
|
||||
this.AddContact(&gobjects.Contact{
|
||||
handle,
|
||||
handle,
|
||||
nick,
|
||||
cwutil.RandomGroupImage(handle),
|
||||
group.GroupServer,
|
||||
0,
|
||||
|
@ -68,9 +72,13 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
|||
} else {
|
||||
contact := the.Peer.GetContact(handle)
|
||||
if contact != nil && handle != contact.Onion {
|
||||
nick, exists := contact.GetAttribute("name")
|
||||
if !exists {
|
||||
nick = contact.Onion
|
||||
}
|
||||
this.AddContact(&gobjects.Contact{
|
||||
handle,
|
||||
handle,
|
||||
nick,
|
||||
cwutil.RandomProfileImage(handle),
|
||||
"",
|
||||
0,
|
||||
|
|
Reference in New Issue