From 862a66f5632b5b90bf7f760d9c56508df67a15da Mon Sep 17 00:00:00 2001
From: Jake Taylor <jake@elixxir.io>
Date: Thu, 8 Sep 2022 16:25:12 -0500
Subject: [PATCH] build with new eventmodel

---
 go.mod                      |  2 +-
 go.sum                      |  4 +--
 indexedDb/implementation.go | 67 +++++++------------------------------
 3 files changed, 15 insertions(+), 58 deletions(-)

diff --git a/go.mod b/go.mod
index 289a7847..78bf2b9a 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ require (
 	github.com/hack-pad/go-indexeddb v0.2.0
 	github.com/pkg/errors v0.9.1
 	github.com/spf13/jwalterweatherman v1.1.0
-	gitlab.com/elixxir/client v1.5.1-0.20220908172911-8967d2e85c80
+	gitlab.com/elixxir/client v1.5.1-0.20220908211108-28a1e0f44f0b
 	gitlab.com/elixxir/crypto v0.0.7-0.20220902165412-5c5e3e990e84
 	gitlab.com/xx_network/primitives v0.0.4-0.20220809193445-9fc0a5209548
 )
diff --git a/go.sum b/go.sum
index ef9a49f0..a89e721b 100644
--- a/go.sum
+++ b/go.sum
@@ -613,8 +613,8 @@ github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
 github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
 gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f h1:yXGvNBqzZwAhDYlSnxPRbgor6JWoOt1Z7s3z1O9JR40=
 gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k=
-gitlab.com/elixxir/client v1.5.1-0.20220908172911-8967d2e85c80 h1:P+l27l4/qRxwkQZktnSKGPm11v5ygogKXoKM9EfYlWc=
-gitlab.com/elixxir/client v1.5.1-0.20220908172911-8967d2e85c80/go.mod h1:HvISFfNXL/XCJ6ynSrEwG9kPEp14i87G5y4wyL1H8R0=
+gitlab.com/elixxir/client v1.5.1-0.20220908211108-28a1e0f44f0b h1:nc3bQH2AWGPyy2Vhy4Z4Nt/wyMZ3tM7TZkiotM6cqm8=
+gitlab.com/elixxir/client v1.5.1-0.20220908211108-28a1e0f44f0b/go.mod h1:HvISFfNXL/XCJ6ynSrEwG9kPEp14i87G5y4wyL1H8R0=
 gitlab.com/elixxir/comms v0.0.4-0.20220907184530-d8eec143a1e8 h1:xbJBQdMdB+mMsKIVXqx7eAWzZmulA3KdRhlbyAk0NIc=
 gitlab.com/elixxir/comms v0.0.4-0.20220907184530-d8eec143a1e8/go.mod h1:xE9NKMAxzvTXmyJ5BMjBZFWMPfvQpw3rB7be2VYvU8E=
 gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
diff --git a/indexedDb/implementation.go b/indexedDb/implementation.go
index a1cd0efc..b1f19b04 100644
--- a/indexedDb/implementation.go
+++ b/indexedDb/implementation.go
@@ -16,10 +16,10 @@ import (
 	"github.com/hack-pad/go-indexeddb/idb"
 	"github.com/pkg/errors"
 	jww "github.com/spf13/jwalterweatherman"
-	"gitlab.com/elixxir/client/channels"
 	"syscall/js"
 	"time"
 
+	"gitlab.com/elixxir/client/channels"
 	"gitlab.com/elixxir/client/cmix/rounds"
 	cryptoBroadcast "gitlab.com/elixxir/crypto/broadcast"
 	cryptoChannel "gitlab.com/elixxir/crypto/channel"
@@ -145,11 +145,11 @@ func (w *wasmModel) LeaveChannel(channelID *id.ID) {
 // the user of the API to filter such called by message ID.
 func (w *wasmModel) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID,
 	senderUsername string, text string, timestamp time.Time, lease time.Duration,
-	_ rounds.Round) {
+	_ rounds.Round, status channels.SentStatus) {
 	parentErr := errors.New("failed to ReceiveMessage")
 
-	err := w.receiveHelper(buildMessage(channelID.Marshal(), messageID.Bytes(), nil,
-		senderUsername, channels.Delivered, text, timestamp, lease))
+	err := w.receiveHelper(buildMessage(channelID.Marshal(), messageID.Bytes(),
+		nil, senderUsername, text, timestamp, lease, status))
 	if err != nil {
 		jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
 	}
@@ -161,12 +161,12 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.Mes
 // Messages may arrive our of order, so a reply in theory can arrive before
 // the initial message, as a result it may be important to buffer replies.
 func (w *wasmModel) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID,
-	replyTo cryptoChannel.MessageID, senderUsername string,
-	text string, timestamp time.Time, lease time.Duration, _ rounds.Round) {
+	replyTo cryptoChannel.MessageID, senderUsername string, text string,
+	timestamp time.Time, lease time.Duration, _ rounds.Round, status channels.SentStatus) {
 	parentErr := errors.New("failed to ReceiveReply")
 
 	err := w.receiveHelper(buildMessage(channelID.Marshal(), messageID.Bytes(),
-		replyTo.Bytes(), senderUsername, channels.Delivered, text, timestamp, lease))
+		replyTo.Bytes(), senderUsername, text, timestamp, lease, status))
 	if err != nil {
 		jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
 	}
@@ -178,54 +178,12 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID, messageID cryptoChannel.Messa
 // Messages may arrive our of order, so a reply in theory can arrive before
 // the initial message, as a result it may be important to buffer reactions.
 func (w *wasmModel) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID,
-	reactionTo cryptoChannel.MessageID, senderUsername string,
-	reaction string, timestamp time.Time, lease time.Duration, _ rounds.Round) {
+	reactionTo cryptoChannel.MessageID, senderUsername string, reaction string,
+	timestamp time.Time, lease time.Duration, _ rounds.Round, status channels.SentStatus) {
 	parentErr := errors.New("failed to ReceiveReaction")
 
 	err := w.receiveHelper(buildMessage(channelID.Marshal(), messageID.Bytes(),
-		reactionTo.Bytes(), senderUsername, channels.Delivered, reaction, timestamp, lease))
-	if err != nil {
-		jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
-	}
-}
-
-// MessageSent is called whenever the user sends a message. It should be
-//designated as "sent" and that delivery is unknown.
-func (w *wasmModel) MessageSent(channelID *id.ID, messageID cryptoChannel.MessageID,
-	myUsername string, text string, timestamp time.Time,
-	lease time.Duration, _ rounds.Round) {
-	parentErr := errors.New("failed to MessageSent")
-
-	err := w.receiveHelper(buildMessage(channelID.Marshal(), messageID.Bytes(),
-		nil, myUsername, channels.Sent, text, timestamp, lease))
-	if err != nil {
-		jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
-	}
-}
-
-// ReplySent is called whenever the user sends a reply. It should be
-// designated as "sent" and that delivery is unknown.
-func (w *wasmModel) ReplySent(channelID *id.ID, messageID cryptoChannel.MessageID,
-	replyTo cryptoChannel.MessageID, myUsername string, text string,
-	timestamp time.Time, lease time.Duration, _ rounds.Round) {
-	parentErr := errors.New("failed to ReplySent")
-
-	err := w.receiveHelper(buildMessage(channelID.Marshal(), messageID.Bytes(),
-		replyTo.Bytes(), myUsername, channels.Sent, text, timestamp, lease))
-	if err != nil {
-		jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
-	}
-}
-
-// ReactionSent is called whenever the user sends a reply. It should be
-// designated as "sent" and that delivery is unknown.
-func (w *wasmModel) ReactionSent(channelID *id.ID, messageID cryptoChannel.MessageID,
-	reactionTo cryptoChannel.MessageID, myUsername string,
-	reaction string, timestamp time.Time, lease time.Duration, _ rounds.Round) {
-	parentErr := errors.New("failed to ReactionSent")
-
-	err := w.receiveHelper(buildMessage(channelID.Marshal(), messageID.Bytes(),
-		reactionTo.Bytes(), myUsername, channels.Sent, reaction, timestamp, lease))
+		reactionTo.Bytes(), senderUsername, reaction, timestamp, lease, status))
 	if err != nil {
 		jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
 	}
@@ -250,8 +208,8 @@ func (w *wasmModel) UpdateSentStatus(messageID cryptoChannel.MessageID,
 // buildMessage is a private helper that converts typical [channels.EventModel]
 // inputs into a basic Message structure for insertion into storage
 func buildMessage(channelID []byte, messageID []byte,
-	parentId []byte, senderUsername string, status channels.SentStatus,
-	text string, timestamp time.Time, lease time.Duration) *Message {
+	parentId []byte, senderUsername string, text string,
+	timestamp time.Time, lease time.Duration, status channels.SentStatus) *Message {
 	return &Message{
 		Id:              messageID,
 		SenderUsername:  senderUsername,
@@ -268,7 +226,6 @@ func buildMessage(channelID []byte, messageID []byte,
 
 // receiveHelper is a private helper for receiving any sort of message
 func (w *wasmModel) receiveHelper(newMessage *Message) error {
-
 	// Convert to jsObject
 	newMessageJson, err := json.Marshal(newMessage)
 	if err != nil {
-- 
GitLab