fix race condition where possible group/contact nick is not set right in ui

This commit is contained in:
Dan Ballard 2019-07-25 15:22:06 -07:00
parent ed904ed79d
commit 4c626dc922
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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,