This commit is contained in:
Sarah Jamie Lewis 2019-07-31 15:35:35 -07:00
parent d13c53cc73
commit 10f892d10d
6 changed files with 30 additions and 33 deletions

View File

@ -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)) gcd.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, cwutil.RandomProfileImage(the.Peer.GetProfile().Onion))
contacts := the.Peer.GetContacts() contacts := the.Peer.GetContacts()
for i := range contacts { for i := range contacts {
contact, _ := the.Peer.GetProfile().GetContact(contacts[i]) contact, _ := the.Peer.GetProfile().GetContact(contacts[i])

View File

@ -85,13 +85,13 @@ func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) {
case event.PeerStateChange: case event.PeerStateChange:
cxnState := connections.ConnectionStateToType[e.Data[event.ConnectionState]] 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 { if !exists {
// Contact does not exist, we will add them but we won't know who they are until they are authenticated // 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 // So if we get any other state from an unknown contact we do nothing
// (the next exists check will fail) // (the next exists check will fail)
if cxnState == connections.AUTHENTICATED { 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)
} }
} }

View File

@ -3,14 +3,14 @@ package gobjects
import "time" import "time"
type Message struct { type Message struct {
Handle string Handle string
From string From string
DisplayName string DisplayName string
Message string Message string
Image string Image string
FromMe bool FromMe bool
MessageID string MessageID string
Timestamp time.Time Timestamp time.Time
Acknowledged bool Acknowledged bool
Error bool Error bool
} }

View File

@ -237,7 +237,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) {
from = "me" from = "me"
} }
ackI,ok := the.AcknowledgementIDs.Load(messages[i].MessageID) ackI, ok := the.AcknowledgementIDs.Load(messages[i].MessageID)
acked := false acked := false
if ok { if ok {
ack := ackI.(*the.AckId) ack := ackI.(*the.AckId)

View File

@ -103,7 +103,7 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
} }
func (this *InterfaceState) AddSendMessageError(peer string, signature string, err string) { func (this *InterfaceState) AddSendMessageError(peer string, signature string, err string) {
ackI,ok := the.AcknowledgementIDs.Load(signature) ackI, ok := the.AcknowledgementIDs.Load(signature)
if ok { if ok {
ack := ackI.(*the.AckId) ack := ackI.(*the.AckId)
ack.Error = true ack.Error = true
@ -134,27 +134,25 @@ func (this *InterfaceState) AddMessage(m *gobjects.Message) {
// Ack message sent to group // Ack message sent to group
this.parentGcd.Acknowledged(m.MessageID) 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) // If we have this group loaded already
messageList, _ := messages.([]*gobjects.Message) if this.parentGcd.CurrentOpenConversation() == m.Handle {
this.messages.Store(m.Handle, append(messageList, m)) // If the message is not from the user then add it, otherwise, just acknowledge.
if !m.FromMe || !m.Acknowledged {
// If we have this group loaded already 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)
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)
}
} else { } else {
c := this.GetContact(m.Handle) this.parentGcd.Acknowledged(m.MessageID)
if c != nil {
c.Badge++
this.UpdateContact(c.Handle)
}
} }
} else {
c := this.GetContact(m.Handle)
if c != nil {
c.Badge++
this.UpdateContact(c.Handle)
}
}
} }

View File

@ -22,7 +22,7 @@ var IPCBridge event.IPCBridge
type AckId struct { type AckId struct {
ID string ID string
Peer string Peer string
Ack bool Ack bool
Error bool Error bool
} }