From f668aa7b7d7c73e1e51b0d4e04cce71c2a9df52b Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 11 Feb 2019 13:05:01 -0800 Subject: [PATCH] Fixing Acks --- go/characters/postmanpat.go | 5 ++++- go/gothings/gcd.go | 5 +++++ go/gothings/uistate.go | 3 ++- go/the/globals.go | 8 +++++++- main.go | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/go/characters/postmanpat.go b/go/characters/postmanpat.go index 6c008b9..4a90eb6 100644 --- a/go/characters/postmanpat.go +++ b/go/characters/postmanpat.go @@ -27,7 +27,10 @@ func andHisBlackAndWhiteCat(incomingMessages chan gobjects.Letter) { m := <-incomingMessages the.Peer.PeerWithOnion(m.To) log.Debugf("sending message!") - the.AcknowledgementIDs[m.To] = append(the.AcknowledgementIDs[m.To], m.MID) + ackID := new(the.AckId) + ackID.ID = m.MID + ackID.Ack = false + the.AcknowledgementIDs[m.To] = append(the.AcknowledgementIDs[m.To], ackID) the.Peer.SendMessageToPeer(m.To, m.Message) } } diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index 30d4a09..901c78c 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -187,6 +187,11 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) { messages[i].FromMe, messages[i].Timestamp.Format(constants.TIME_FORMAT), ) + for _,id := range the.AcknowledgementIDs[messages[i].Handle] { + if int(id.ID) == messages[i].MessageID && id.Ack{ + this.Acknowledged(id.ID) + } + } } } diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index 547524f..26bc87b 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -93,7 +93,8 @@ func (this *InterfaceState) AddMessage(m *gobjects.Message) { // If an ack, swallow the message and ack from the list. acklist := the.AcknowledgementIDs[m.From] for _,ack := range acklist { - this.parentGcd.Acknowledged(ack) + ack.Ack = true + this.parentGcd.Acknowledged(ack.ID) } } else { this.messages[m.Handle] = append(this.messages[m.Handle], m) diff --git a/go/the/globals.go b/go/the/globals.go index 09d68f4..afaef4c 100644 --- a/go/the/globals.go +++ b/go/the/globals.go @@ -8,4 +8,10 @@ import ( var CwtchApp app.Application var Peer libPeer.CwtchPeer var CwtchDir string -var AcknowledgementIDs map[string][]uint + +type AckId struct { + ID uint + Ack bool +} + +var AcknowledgementIDs map[string][]*AckId diff --git a/main.go b/main.go index 01fd0d7..dff9a0b 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func main() { // our globals gcd := gothings.NewGrandCentralDispatcher(nil) gcd.UIState = gothings.NewUIState(gcd) - the.AcknowledgementIDs = make(map[string][]uint) + the.AcknowledgementIDs = make(map[string][]*the.AckId) gcd.OutgoingMessages = make(chan gobjects.Letter, 1000) //TODO: put theme stuff somewhere better