From 4c96e1c39f41cca797610503f6c6c6e81da3089c Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Mon, 27 Feb 2023 18:49:39 +0000
Subject: [PATCH] add logs to receive in xxdk-wasm

---
 indexedDb/impl/dm/implementation.go | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/indexedDb/impl/dm/implementation.go b/indexedDb/impl/dm/implementation.go
index 8280d7b5..d23c1fe9 100644
--- a/indexedDb/impl/dm/implementation.go
+++ b/indexedDb/impl/dm/implementation.go
@@ -98,6 +98,7 @@ func (w *wasmModel) Receive(messageID message.ID, nickname string, text []byte,
 	pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, timestamp time.Time,
 	round rounds.Round, mType dm.MessageType, status dm.Status) uint64 {
 	parentErr := errors.New("failed to Receive")
+	jww.TRACE.Printf("[DM indexedDB] Receive(%s)", messageID)
 
 	// If there is no extant Conversation, create one.
 	_, err := impl.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey))
@@ -132,6 +133,8 @@ func (w *wasmModel) Receive(messageID message.ID, nickname string, text []byte,
 		jww.ERROR.Printf("Failed to receive Message: %+v", err)
 	}
 
+	jww.TRACE.Printf("[DM indexedDB] Calling ReceiveMessageCB(%v, %v, f)",
+		uuid, pubKey)
 	go w.receivedMessageCB(uuid, pubKey, false)
 	return uuid
 }
@@ -140,6 +143,7 @@ func (w *wasmModel) ReceiveText(messageID message.ID, nickname, text string,
 	pubKey ed25519.PublicKey, dmToken uint32, codeset uint8,
 	timestamp time.Time, round rounds.Round, status dm.Status) uint64 {
 	parentErr := errors.New("failed to ReceiveText")
+	jww.TRACE.Printf("[DM indexedDB] ReceiveText(%s)", messageID)
 
 	// If there is no extant Conversation, create one.
 	_, err := impl.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey))
@@ -176,6 +180,8 @@ func (w *wasmModel) ReceiveText(messageID message.ID, nickname, text string,
 		jww.ERROR.Printf("Failed to receive Message: %+v", err)
 	}
 
+	jww.TRACE.Printf("[DM indexedDB] Calling ReceiveMessageCB(%v, %v, f)",
+		uuid, pubKey)
 	go w.receivedMessageCB(uuid, pubKey, false)
 	return uuid
 }
@@ -184,6 +190,7 @@ func (w *wasmModel) ReceiveReply(messageID, reactionTo message.ID, nickname,
 	text string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8,
 	timestamp time.Time, round rounds.Round, status dm.Status) uint64 {
 	parentErr := errors.New("failed to ReceiveReply")
+	jww.TRACE.Printf("[DM indexedDB] ReceiveReply(%s)", messageID)
 
 	// If there is no extant Conversation, create one.
 	_, err := impl.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey))
@@ -220,6 +227,8 @@ func (w *wasmModel) ReceiveReply(messageID, reactionTo message.ID, nickname,
 		jww.ERROR.Printf("Failed to receive Message: %+v", err)
 	}
 
+	jww.TRACE.Printf("[DM indexedDB] Calling ReceiveMessageCB(%v, %v, f)",
+		uuid, pubKey)
 	go w.receivedMessageCB(uuid, pubKey, false)
 	return uuid
 }
@@ -228,6 +237,7 @@ func (w *wasmModel) ReceiveReaction(messageID, _ message.ID, nickname,
 	reaction string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8,
 	timestamp time.Time, round rounds.Round, status dm.Status) uint64 {
 	parentErr := errors.New("failed to ReceiveText")
+	jww.TRACE.Printf("[DM indexedDB] ReceiveReaction(%s)", messageID)
 
 	// If there is no extant Conversation, create one.
 	_, err := impl.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey))
@@ -264,6 +274,8 @@ func (w *wasmModel) ReceiveReaction(messageID, _ message.ID, nickname,
 		jww.ERROR.Printf("Failed to receive Message: %+v", err)
 	}
 
+	jww.TRACE.Printf("[DM indexedDB] Calling ReceiveMessageCB(%v, %v, f)",
+		uuid, pubKey)
 	go w.receivedMessageCB(uuid, pubKey, false)
 	return uuid
 }
@@ -277,6 +289,8 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64, messageID message.ID,
 	//        special version of receiveHelper)
 	w.updateMux.Lock()
 	defer w.updateMux.Unlock()
+	jww.TRACE.Printf("[DM indexedDB] UpdateSentStatus(%d, %s, ...)",
+		uuid, messageID)
 
 	// Convert messageID to the key generated by json.Marshal
 	key := js.ValueOf(uuid)
@@ -316,6 +330,9 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64, messageID message.ID,
 	if err != nil {
 		jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
 	}
+
+	jww.TRACE.Printf("[DM indexedDB] Calling ReceiveMessageCB(%v, %v, t)",
+		uuid, newMessage.ConversationPubKey)
 	go w.receivedMessageCB(uuid, newMessage.ConversationPubKey, true)
 }
 
-- 
GitLab