Skip to content
Snippets Groups Projects
Commit 88b6b9d7 authored by Jake Taylor's avatar Jake Taylor
Browse files

cleaner logging

parent b635941d
No related branches found
No related tags found
1 merge request!76added first implementation for disabling users in DM indexedDb package
This commit is part of merge request !76. Comments created here will be created in the context of that merge request.
...@@ -395,7 +395,7 @@ func (w *wasmModel) GetConversation(senderPubKey ed25519.PublicKey) *dm.ModelCon ...@@ -395,7 +395,7 @@ func (w *wasmModel) GetConversation(senderPubKey ed25519.PublicKey) *dm.ModelCon
// getConversation is a helper that returns the Conversation with the given senderPubKey. // getConversation is a helper that returns the Conversation with the given senderPubKey.
func (w *wasmModel) getConversation(senderPubKey ed25519.PublicKey) (*Conversation, error) { func (w *wasmModel) getConversation(senderPubKey ed25519.PublicKey) (*Conversation, error) {
resultObj, err := impl.Get(w.db, conversationStoreName, utils.CopyBytesToJS(senderPubKey)) resultObj, err := impl.Get(w.db, conversationStoreName, impl.EncodeBytes(senderPubKey))
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -48,7 +48,7 @@ func EncodeBytes(input []byte) js.Value { ...@@ -48,7 +48,7 @@ func EncodeBytes(input []byte) js.Value {
// Get is a generic helper for getting values from the given [idb.ObjectStore]. // Get is a generic helper for getting values from the given [idb.ObjectStore].
// Only usable by primary key. // Only usable by primary key.
func Get(db *idb.Database, objectStoreName string, key js.Value) (js.Value, error) { func Get(db *idb.Database, objectStoreName string, key js.Value) (js.Value, error) {
parentErr := errors.Errorf("failed to Get %s/%s", objectStoreName, key) parentErr := errors.Errorf("failed to Get %s", objectStoreName)
// Prepare the Transaction // Prepare the Transaction
txn, err := db.Transaction(idb.TransactionReadOnly, objectStoreName) txn, err := db.Transaction(idb.TransactionReadOnly, objectStoreName)
...@@ -82,8 +82,8 @@ func Get(db *idb.Database, objectStoreName string, key js.Value) (js.Value, erro ...@@ -82,8 +82,8 @@ func Get(db *idb.Database, objectStoreName string, key js.Value) (js.Value, erro
} }
// Process result into string // Process result into string
jww.DEBUG.Printf("Got from %s/%s: %s", jww.DEBUG.Printf("Got from %s: %s",
objectStoreName, key, utils.JsToJson(resultObj)) objectStoreName, utils.JsToJson(resultObj))
return resultObj, nil return resultObj, nil
} }
...@@ -131,8 +131,8 @@ func GetAll(db *idb.Database, objectStoreName string) ([]js.Value, error) { ...@@ -131,8 +131,8 @@ func GetAll(db *idb.Database, objectStoreName string) ([]js.Value, error) {
// [idb.ObjectStore] using the given [idb.Index]. // [idb.ObjectStore] using the given [idb.Index].
func GetIndex(db *idb.Database, objectStoreName, func GetIndex(db *idb.Database, objectStoreName,
indexName string, key js.Value) (js.Value, error) { indexName string, key js.Value) (js.Value, error) {
parentErr := errors.Errorf("failed to GetIndex %s/%s/%s", parentErr := errors.Errorf("failed to GetIndex %s/%s",
objectStoreName, indexName, key) objectStoreName, indexName)
// Prepare the Transaction // Prepare the Transaction
txn, err := db.Transaction(idb.TransactionReadOnly, objectStoreName) txn, err := db.Transaction(idb.TransactionReadOnly, objectStoreName)
...@@ -171,8 +171,8 @@ func GetIndex(db *idb.Database, objectStoreName, ...@@ -171,8 +171,8 @@ func GetIndex(db *idb.Database, objectStoreName,
} }
// Process result into string // Process result into string
jww.DEBUG.Printf("Got from %s/%s/%s: %s", jww.DEBUG.Printf("Got from %s/%s: %s",
objectStoreName, indexName, key, utils.JsToJson(resultObj)) objectStoreName, indexName, utils.JsToJson(resultObj))
return resultObj, nil return resultObj, nil
} }
...@@ -210,7 +210,7 @@ func Put(db *idb.Database, objectStoreName string, value js.Value) (js.Value, er ...@@ -210,7 +210,7 @@ func Put(db *idb.Database, objectStoreName string, value js.Value) (js.Value, er
// Delete is a generic helper for removing values from the given // Delete is a generic helper for removing values from the given
// [idb.ObjectStore]. Only usable by primary key. // [idb.ObjectStore]. Only usable by primary key.
func Delete(db *idb.Database, objectStoreName string, key js.Value) error { func Delete(db *idb.Database, objectStoreName string, key js.Value) error {
parentErr := errors.Errorf("failed to Delete %s/%s", objectStoreName, key) parentErr := errors.Errorf("failed to Delete %s", objectStoreName)
// Prepare the Transaction // Prepare the Transaction
txn, err := db.Transaction(idb.TransactionReadWrite, objectStoreName) txn, err := db.Transaction(idb.TransactionReadWrite, objectStoreName)
......
...@@ -113,7 +113,7 @@ func (emb *dmReceiverBuilder) Build(path string) bindings.DMReceiver { ...@@ -113,7 +113,7 @@ func (emb *dmReceiverBuilder) Build(path string) bindings.DMReceiver {
func NewDMClient(_ js.Value, args []js.Value) any { func NewDMClient(_ js.Value, args []js.Value) any {
privateIdentity := utils.CopyBytesToGo(args[1]) privateIdentity := utils.CopyBytesToGo(args[1])
em := &dmReceiverBuilder{args[2].IsNaN} em := &dmReceiverBuilder{args[2].Invoke}
cm, err := bindings.NewDMClient(args[0].Int(), privateIdentity, em) cm, err := bindings.NewDMClient(args[0].Int(), privateIdentity, em)
if err != nil { if err != nil {
...@@ -473,8 +473,8 @@ func (dmc *DMClient) SetNickname(_ js.Value, args []js.Value) any { ...@@ -473,8 +473,8 @@ func (dmc *DMClient) SetNickname(_ js.Value, args []js.Value) any {
// Returns: // Returns:
// - The nickname (string). // - The nickname (string).
// - Throws TypeError if the channel has no nickname set. // - Throws TypeError if the channel has no nickname set.
func (ch *DMClient) GetNickname(_ js.Value, args []js.Value) any { func (dmc *DMClient) GetNickname(_ js.Value, _ []js.Value) any {
nickname, err := ch.api.GetNickname() nickname, err := dmc.api.GetNickname()
if err != nil { if err != nil {
utils.Throw(utils.TypeError, err) utils.Throw(utils.TypeError, err)
return nil return nil
...@@ -490,7 +490,7 @@ func (ch *DMClient) GetNickname(_ js.Value, args []js.Value) any { ...@@ -490,7 +490,7 @@ func (ch *DMClient) GetNickname(_ js.Value, args []js.Value) any {
// //
// Returns: // Returns:
// - The storage tag (string). // - The storage tag (string).
func (dmc *DMClient) GetDatabaseName(_ js.Value, args []js.Value) any { func (dmc *DMClient) GetDatabaseName(_ js.Value, _ []js.Value) any {
return base64.RawStdEncoding.EncodeToString(dmc.api.GetPublicKey()) + return base64.RawStdEncoding.EncodeToString(dmc.api.GetPublicKey()) +
"_speakeasy_dm" "_speakeasy_dm"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment