From 4c626dc922bcb6716b195e529e2cb4c6e282e647 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 25 Jul 2019 15:22:06 -0700 Subject: [PATCH] fix race condition where possible group/contact nick is not set right in ui --- go/characters/incominglistener.go | 1 - go/gothings/uistate.go | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/go/characters/incominglistener.go b/go/characters/incominglistener.go index 14ae72a3..40a58224 100644 --- a/go/characters/incominglistener.go +++ b/go/characters/incominglistener.go @@ -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 diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index 9ad46e9d..5185f559 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -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,