Skip to content

Commit 7fcd514

Browse files
committed
style: format wake lock
1 parent 3f9703b commit 7fcd514

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/services/wake_lock.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,14 @@ pub fn enable_wake_lock() {
3333
let Some(document) = window.document() else {
3434
return;
3535
};
36-
if document.visibility_state()
37-
== web_sys::VisibilityState::Visible
38-
{
36+
if document.visibility_state() == web_sys::VisibilityState::Visible {
3937
let _ = request_wake_lock().await;
4038
}
4139
});
4240
});
4341

44-
let _ = document.add_event_listener_with_callback(
45-
"visibilitychange",
46-
closure.as_ref().unchecked_ref(),
47-
);
42+
let _ = document
43+
.add_event_listener_with_callback("visibilitychange", closure.as_ref().unchecked_ref());
4844
// Intentionally leak the closure so it lives for the page lifetime.
4945
closure.forget();
5046
}
@@ -62,14 +58,14 @@ async fn request_wake_lock() -> Result<(), String> {
6258
let navigator = window.navigator();
6359

6460
// Check that navigator.wakeLock exists (not all browsers support it yet).
65-
let wake_lock = Reflect::get(&navigator, &JsValue::from_str("wakeLock"))
66-
.map_err(|e| format!("{:?}", e))?;
61+
let wake_lock =
62+
Reflect::get(&navigator, &JsValue::from_str("wakeLock")).map_err(|e| format!("{:?}", e))?;
6763
if wake_lock.is_undefined() || wake_lock.is_null() {
6864
return Ok(()); // API not supported – silently skip
6965
}
7066

71-
let request_fn = Reflect::get(&wake_lock, &JsValue::from_str("request"))
72-
.map_err(|e| format!("{:?}", e))?;
67+
let request_fn =
68+
Reflect::get(&wake_lock, &JsValue::from_str("request")).map_err(|e| format!("{:?}", e))?;
7369
let request_fn: Function = request_fn
7470
.dyn_into()
7571
.map_err(|_| "wakeLock.request is not a function".to_string())?;

0 commit comments

Comments
 (0)