From 10f892d10df61549657364e73d2078ba62de76e6 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 31 Jul 2019 15:35:35 -0700 Subject: [PATCH] fmt --- go/characters/appEventListener.go | 1 - go/characters/incominglistener.go | 4 ++-- go/gobjects/message.go | 18 ++++++++-------- go/gothings/gcd.go | 2 +- go/gothings/uistate.go | 36 +++++++++++++++---------------- go/the/globals.go | 2 +- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/go/characters/appEventListener.go b/go/characters/appEventListener.go index 67d552b0..3ee2f498 100644 --- a/go/characters/appEventListener.go +++ b/go/characters/appEventListener.go @@ -76,7 +76,6 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool gcd.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, cwutil.RandomProfileImage(the.Peer.GetProfile().Onion)) - contacts := the.Peer.GetContacts() for i := range contacts { contact, _ := the.Peer.GetProfile().GetContact(contacts[i]) diff --git a/go/characters/incominglistener.go b/go/characters/incominglistener.go index 1fc6ff6f..4b1602dc 100644 --- a/go/characters/incominglistener.go +++ b/go/characters/incominglistener.go @@ -85,13 +85,13 @@ func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) { case event.PeerStateChange: cxnState := connections.ConnectionStateToType[e.Data[event.ConnectionState]] - _,exists := the.Peer.GetProfile().Contacts[e.Data[event.RemotePeer]] + _, exists := the.Peer.GetProfile().Contacts[e.Data[event.RemotePeer]] if !exists { // Contact does not exist, we will add them but we won't know who they are until they are authenticated // So if we get any other state from an unknown contact we do nothing // (the next exists check will fail) if cxnState == connections.AUTHENTICATED { - the.Peer.AddContact(e.Data[event.RemotePeer],e.Data[event.RemotePeer],false) + the.Peer.AddContact(e.Data[event.RemotePeer], e.Data[event.RemotePeer], false) } } diff --git a/go/gobjects/message.go b/go/gobjects/message.go index 8001dcad..01284ffb 100644 --- a/go/gobjects/message.go +++ b/go/gobjects/message.go @@ -3,14 +3,14 @@ package gobjects import "time" type Message struct { - Handle string - From string - DisplayName string - Message string - Image string - FromMe bool - MessageID string - Timestamp time.Time + Handle string + From string + DisplayName string + Message string + Image string + FromMe bool + MessageID string + Timestamp time.Time Acknowledged bool - Error bool + Error bool } diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index d2399c28..29e38e1f 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -237,7 +237,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) { from = "me" } - ackI,ok := the.AcknowledgementIDs.Load(messages[i].MessageID) + ackI, ok := the.AcknowledgementIDs.Load(messages[i].MessageID) acked := false if ok { ack := ackI.(*the.AckId) diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index c441f9e9..61581b8e 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -103,7 +103,7 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact { } func (this *InterfaceState) AddSendMessageError(peer string, signature string, err string) { - ackI,ok := the.AcknowledgementIDs.Load(signature) + ackI, ok := the.AcknowledgementIDs.Load(signature) if ok { ack := ackI.(*the.AckId) ack.Error = true @@ -134,27 +134,25 @@ func (this *InterfaceState) AddMessage(m *gobjects.Message) { // Ack message sent to group this.parentGcd.Acknowledged(m.MessageID) + messages, _ := this.messages.Load(m.Handle) + messageList, _ := messages.([]*gobjects.Message) + this.messages.Store(m.Handle, append(messageList, m)) - messages, _ := this.messages.Load(m.Handle) - messageList, _ := messages.([]*gobjects.Message) - this.messages.Store(m.Handle, append(messageList, m)) - - // If we have this group loaded already - if this.parentGcd.CurrentOpenConversation() == m.Handle { - // If the message is not from the user then add it, otherwise, just acknowledge. - if !m.FromMe || !m.Acknowledged { - this.parentGcd.AppendMessage(m.Handle, m.From, m.DisplayName, m.Message, m.Image, m.MessageID, m.FromMe, m.Timestamp.Format(constants.TIME_FORMAT), m.Acknowledged, m.Error) - } else { - this.parentGcd.Acknowledged(m.MessageID) - } + // If we have this group loaded already + if this.parentGcd.CurrentOpenConversation() == m.Handle { + // If the message is not from the user then add it, otherwise, just acknowledge. + if !m.FromMe || !m.Acknowledged { + this.parentGcd.AppendMessage(m.Handle, m.From, m.DisplayName, m.Message, m.Image, m.MessageID, m.FromMe, m.Timestamp.Format(constants.TIME_FORMAT), m.Acknowledged, m.Error) } else { - c := this.GetContact(m.Handle) - if c != nil { - c.Badge++ - this.UpdateContact(c.Handle) - } + this.parentGcd.Acknowledged(m.MessageID) } - + } else { + c := this.GetContact(m.Handle) + if c != nil { + c.Badge++ + this.UpdateContact(c.Handle) + } + } } diff --git a/go/the/globals.go b/go/the/globals.go index 937990b3..013a76cb 100644 --- a/go/the/globals.go +++ b/go/the/globals.go @@ -22,7 +22,7 @@ var IPCBridge event.IPCBridge type AckId struct { ID string - Peer string + Peer string Ack bool Error bool }