fix(indexeddb): Fix wasm_bindgen::JsValue::(from|to)_serde warnings.

`wasm_bindgen::JsValue::(from|to)_serde` now emit warnings because of a
circular dependency. To solve this problem, this patch now uses `gloo-utils`,
see https://rustwasm.github.io/wasm-bindgen/reference/arbitrary-data-with-serde.html#an-alternative-approach---using-json.

Ideally, we would like to use `serde_wasm_bindgen` but the behaviour isn't
the same. `gloo-utils` serializes and deserialized through JSON, whilst
`serde_wasm_bindgen` manipulates the `JsValue` directly which can be better or
worst dependending of the case. This patch conserves the JSON approach as it
was the previous and tested one.
This commit is contained in:
Ivan Enderlin
2022-11-02 08:59:37 +01:00
parent 2b4f4b17c3
commit da93cf7dc4
3 changed files with 5 additions and 2 deletions

View File

@@ -35,7 +35,8 @@ serde = "1.0.136"
serde_json = "1.0.79"
thiserror = "1.0.30"
tracing = { workspace = true }
wasm-bindgen = { version = "0.2.80", features = ["serde-serialize"] }
wasm-bindgen = "0.2.83"
gloo-utils = { version = "0.1", features = ["serde"] }
web-sys = { version = "0.3.57", features = ["IdbKeyRange"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
@@ -48,4 +49,4 @@ matrix-sdk-common = { path = "../matrix-sdk-common", features = ["js"] }
matrix-sdk-crypto = { path = "../matrix-sdk-crypto", features = ["js", "testing"] }
matrix-sdk-test = { path = "../../testing/matrix-sdk-test" }
uuid = "1.0.0"
wasm-bindgen-test = "0.3.30"
wasm-bindgen-test = "0.3.33"

View File

@@ -19,6 +19,7 @@ use std::{
use async_trait::async_trait;
use dashmap::DashSet;
use gloo_utils::format::JsValueSerdeExt;
use matrix_sdk_base::locks::Mutex;
use matrix_sdk_crypto::{
olm::{

View File

@@ -23,6 +23,7 @@ use std::{
use anyhow::anyhow;
use async_trait::async_trait;
use derive_builder::Builder;
use gloo_utils::format::JsValueSerdeExt;
use js_sys::Date as JsDate;
use matrix_sdk_base::{
deserialized_responses::MemberEvent,