Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
c23af33e
Commit
c23af33e
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
fix formatting crash and DM EM impl bool logic
parent
1b968576
No related branches found
No related tags found
1 merge request
!67
fix for latest client release
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
indexedDb/impl/dm/implementation.go
+13
-18
13 additions, 18 deletions
indexedDb/impl/dm/implementation.go
with
13 additions
and
18 deletions
indexedDb/impl/dm/implementation.go
+
13
−
18
View file @
c23af33e
...
@@ -30,8 +30,7 @@ import (
...
@@ -30,8 +30,7 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
)
)
// wasmModel implements dm.EventModel interface, which uses the channels system
// wasmModel implements dm.EventModel interface backed by IndexedDb.
// passed an object that adheres to in order to get events on the channel.
// NOTE: This model is NOT thread safe - it is the responsibility of the
// NOTE: This model is NOT thread safe - it is the responsibility of the
// caller to ensure that its methods are called sequentially.
// caller to ensure that its methods are called sequentially.
type
wasmModel
struct
{
type
wasmModel
struct
{
...
@@ -217,9 +216,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
...
@@ -217,9 +216,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
data
string
,
partnerKey
,
senderKey
ed25519
.
PublicKey
,
dmToken
uint32
,
codeset
uint8
,
data
string
,
partnerKey
,
senderKey
ed25519
.
PublicKey
,
dmToken
uint32
,
codeset
uint8
,
timestamp
time
.
Time
,
round
rounds
.
Round
,
mType
dm
.
MessageType
,
status
dm
.
Status
)
(
uint64
,
error
)
{
timestamp
time
.
Time
,
round
rounds
.
Round
,
mType
dm
.
MessageType
,
status
dm
.
Status
)
(
uint64
,
error
)
{
// Keep track of whether Conversation was altered
// FIXME: this is very similar to updateConversation
//. below. Can we merge them?
conversationUpdated
:=
false
conversationUpdated
:=
false
result
,
err
:=
w
.
getConversation
(
partnerKey
)
result
,
err
:=
w
.
getConversation
(
partnerKey
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -240,7 +236,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
...
@@ -240,7 +236,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
jww
.
DEBUG
.
Printf
(
jww
.
DEBUG
.
Printf
(
"[DM indexedDB] Conversation with %s already joined"
,
nickname
)
"[DM indexedDB] Conversation with %s already joined"
,
nickname
)
updateConversation
:=
false
// Update Conversation if nickname was altered
// Update Conversation if nickname was altered
isFromPartner
:=
bytes
.
Equal
(
result
.
Pubkey
,
senderKey
)
isFromPartner
:=
bytes
.
Equal
(
result
.
Pubkey
,
senderKey
)
nicknameChanged
:=
result
.
Nickname
!=
nickname
nicknameChanged
:=
result
.
Nickname
!=
nickname
...
@@ -248,19 +243,21 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
...
@@ -248,19 +243,21 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
jww
.
DEBUG
.
Printf
(
jww
.
DEBUG
.
Printf
(
"[DM indexedDB] Updating from nickname %s to %s"
,
"[DM indexedDB] Updating from nickname %s to %s"
,
result
.
Nickname
,
nickname
)
result
.
Nickname
,
nickname
)
updateC
onversation
=
true
c
onversation
Updated
=
true
}
}
// Fix conversation if dmToken is altered
// Fix conversation if dmToken is altered
dmTokenChanged
:=
result
.
Token
!=
dmToken
dmTokenChanged
:=
result
.
Token
!=
dmToken
if
isFromPartner
&&
dmTokenChanged
{
if
isFromPartner
&&
dmTokenChanged
{
jww
.
WARN
.
Printf
(
jww
.
WARN
.
Printf
(
"[DM indexedDB] Updating from dmToken %
s
to %
s
"
,
"[DM indexedDB] Updating from dmToken %
d
to %
d
"
,
result
.
Token
,
dmToken
)
result
.
Token
,
dmToken
)
updateConversation
=
true
conversationUpdated
=
true
}
}
}
if
updateConversation
{
// Update the conversation in storage, if needed
if
conversationUpdated
{
err
=
w
.
upsertConversation
(
nickname
,
result
.
Pubkey
,
err
=
w
.
upsertConversation
(
nickname
,
result
.
Pubkey
,
result
.
Token
,
result
.
CodesetVersion
,
result
.
Token
,
result
.
CodesetVersion
,
result
.
Blocked
)
result
.
Blocked
)
...
@@ -270,8 +267,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
...
@@ -270,8 +267,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
conversationUpdated
=
true
conversationUpdated
=
true
}
}
}
// Handle encryption, if it is present
// Handle encryption, if it is present
textBytes
:=
[]
byte
(
data
)
textBytes
:=
[]
byte
(
data
)
if
w
.
cipher
!=
nil
{
if
w
.
cipher
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment