Skip to content
Snippets Groups Projects
Commit 3f6909ff authored by Jono Wenger's avatar Jono Wenger
Browse files

Update channels bindings for indexedDb changes

parent d675b419
No related branches found
No related tags found
2 merge requests!60Revert "Fail a test to be sure it works",!8Updates to match the client fullyDecentrilizedChannels branch
......@@ -10,6 +10,7 @@
package wasm
import (
"gitlab.com/xx_network/primitives/id"
"syscall/js"
"gitlab.com/elixxir/client/bindings"
......@@ -229,6 +230,12 @@ func LoadChannelsManager(_ js.Value, args []js.Value) interface{} {
// using [Cmix.GetID].
// - args[1] - Bytes of a private identity ([channel.PrivateIdentity]) that is
// generated by [GenerateChannelIdentity] (Uint8Array).
// - args[2] - Function that takes in the same parameters as
// [indexedDb.MessageReceivedCallback]. On the Javascript side, the uuid is
// returned as an int and the channelID as a Uint8Array. The row in the
// database that was updated can be found using the UUID. The channel ID is
// provided so that the recipient can filter if they want to the processes
// the update now or not.
//
// Returns a promise:
// - Resolves to a Javascript representation of the [ChannelsManager] object.
......@@ -237,9 +244,16 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
cmixID := args[0].Int()
privateIdentity := utils.CopyBytesToGo(args[1])
fn := func(uuid uint64, channelID *id.ID) {
args[2].Invoke(uuid, channelID.Marshal())
}
model := indexedDb.NewWASMEventModelBuilder(fn)
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
cm, err := bindings.NewChannelsManagerGoEventModel(
cmixID, privateIdentity, indexedDb.NewWasmEventModel)
cmixID, privateIdentity, model)
if err != nil {
reject(utils.JsTrace(err))
} else {
......@@ -263,6 +277,12 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
// using [Cmix.GetID].
// - args[1] - The storage tag associated with the previously created channel
// manager and retrieved with [ChannelsManager.GetStorageTag] (string).
// - args[2] - Function that takes in the same parameters as
// [indexedDb.MessageReceivedCallback]. On the Javascript side, the uuid is
// returned as an int and the channelID as a Uint8Array. The row in the
// database that was updated can be found using the UUID. The channel ID is
// provided so that the recipient can filter if they want to the processes
// the update now or not.
//
// Returns a promise:
// - Resolves to a Javascript representation of the [ChannelsManager] object.
......@@ -271,9 +291,16 @@ func LoadChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
cmixID := args[0].Int()
storageTag := args[1].String()
fn := func(uuid uint64, channelID *id.ID) {
args[2].Invoke(uuid, channelID.Marshal())
}
model := indexedDb.NewWASMEventModelBuilder(fn)
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
cm, err := bindings.LoadChannelsManagerGoEventModel(
cmixID, storageTag, indexedDb.NewWasmEventModel)
cmixID, storageTag, model)
if err != nil {
reject(utils.JsTrace(err))
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment