Skip to content

Commit

Permalink
Remove windowless sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGiorgio committed Nov 9, 2023
1 parent 0f2d1b8 commit 52e089e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions mutiny-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ test-utils = []
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.84"
wasm-bindgen-futures = { version = "0.4.33" }
web-sys = { version = "0.3.60", features = ["console"] }
js-sys = { version = "0.3.60" }
gloo-net = { version = "0.2.4" }
instant = { version = "0.1", features = ["wasm-bindgen"] }
getrandom = { version = "0.2", features = ["js"] }
windowless_sleep = "0.1.1"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
web-sys = { version = "0.3.60", features = ["console"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["rt"] }
Expand Down
9 changes: 8 additions & 1 deletion mutiny-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ pub(crate) fn min_lightning_amount(network: Network) -> u64 {
pub async fn sleep(millis: i32) {
#[cfg(target_arch = "wasm32")]
{
windowless_sleep::sleep(millis).await;
let mut cb = |resolve: js_sys::Function, _reject: js_sys::Function| {
web_sys::window()
.unwrap()
.set_timeout_with_callback_and_timeout_and_arguments_0(&resolve, millis)
.unwrap();
};
let p = js_sys::Promise::new(&mut cb);
wasm_bindgen_futures::JsFuture::from(p).await.unwrap();
}
#[cfg(not(target_arch = "wasm32"))]
{
Expand Down
3 changes: 1 addition & 2 deletions mutiny-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ log = "0.4.17"
rexie = "0.4"
js-sys = "0.3.60"
gloo-utils = { version = "0.1.6", features = ["serde"] }
web-sys = { version = "0.3.60", features = ["console"] }
bip39 = { version = "2.0.0" }
getrandom = { version = "0.2", features = ["js"] }
futures = "0.3.25"
urlencoding = "2.1.2"
once_cell = "1.18.0"
windowless_sleep = "0.1.1"

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
Expand All @@ -51,7 +51,6 @@ console_error_panic_hook = { version = "0.1.6", optional = true }
[dev-dependencies]
mutiny-core = { path = "../mutiny-core", features = ["test-utils"] }
wasm-bindgen-test = "0.3.33"
web-sys = { version = "0.3.60", features = ["console"] }

[features]
default = []
Expand Down

0 comments on commit 52e089e

Please sign in to comment.