fmt
This commit is contained in:
parent
d13c53cc73
commit
10f892d10d
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ var IPCBridge event.IPCBridge
|
|||
|
||||
type AckId struct {
|
||||
ID string
|
||||
Peer string
|
||||
Peer string
|
||||
Ack bool
|
||||
Error bool
|
||||
}
|
||||
|
|
Reference in New Issue