Silence warnings, run cargo fmt
This commit is contained in:
parent
fe1c1d3655
commit
af1c767f5f
77 changed files with 1904 additions and 903 deletions
|
|
@ -75,9 +75,7 @@ pub fn NotificationToast(
|
|||
|
||||
// Clear any existing timer
|
||||
if let Some(handle) = timer_handle_effect.borrow_mut().take() {
|
||||
web_sys::window()
|
||||
.unwrap()
|
||||
.clear_timeout_with_handle(handle);
|
||||
web_sys::window().unwrap().clear_timeout_with_handle(handle);
|
||||
}
|
||||
|
||||
// Start new timer if notification is present
|
||||
|
|
@ -89,13 +87,16 @@ pub fn NotificationToast(
|
|||
let closure = wasm_bindgen::closure::Closure::once(Box::new(move || {
|
||||
on_dismiss.run(id);
|
||||
timer_handle_inner.borrow_mut().take();
|
||||
}) as Box<dyn FnOnce()>);
|
||||
})
|
||||
as Box<dyn FnOnce()>);
|
||||
|
||||
if let Some(window) = web_sys::window() {
|
||||
if let Ok(handle) = window.set_timeout_with_callback_and_timeout_and_arguments_0(
|
||||
closure.as_ref().unchecked_ref(),
|
||||
5000, // 5 second auto-dismiss
|
||||
) {
|
||||
if let Ok(handle) = window
|
||||
.set_timeout_with_callback_and_timeout_and_arguments_0(
|
||||
closure.as_ref().unchecked_ref(),
|
||||
5000, // 5 second auto-dismiss
|
||||
)
|
||||
{
|
||||
*timer_handle_effect.borrow_mut() = Some(handle);
|
||||
}
|
||||
}
|
||||
|
|
@ -110,8 +111,9 @@ pub fn NotificationToast(
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
let closure_holder: Rc<RefCell<Option<wasm_bindgen::closure::Closure<dyn Fn(web_sys::KeyboardEvent)>>>> =
|
||||
Rc::new(RefCell::new(None));
|
||||
let closure_holder: Rc<
|
||||
RefCell<Option<wasm_bindgen::closure::Closure<dyn Fn(web_sys::KeyboardEvent)>>>,
|
||||
> = Rc::new(RefCell::new(None));
|
||||
let closure_holder_clone = closure_holder.clone();
|
||||
|
||||
Effect::new(move |_| {
|
||||
|
|
@ -140,37 +142,37 @@ pub fn NotificationToast(
|
|||
let on_history = on_history.clone();
|
||||
let on_dismiss = on_dismiss.clone();
|
||||
|
||||
let closure = wasm_bindgen::closure::Closure::<dyn Fn(web_sys::KeyboardEvent)>::new(move |ev: web_sys::KeyboardEvent| {
|
||||
let key = ev.key();
|
||||
match key.as_str() {
|
||||
"r" | "R" => {
|
||||
ev.prevent_default();
|
||||
on_reply.run(display_name.clone());
|
||||
on_dismiss.run(notif_id);
|
||||
let closure = wasm_bindgen::closure::Closure::<dyn Fn(web_sys::KeyboardEvent)>::new(
|
||||
move |ev: web_sys::KeyboardEvent| {
|
||||
let key = ev.key();
|
||||
match key.as_str() {
|
||||
"r" | "R" => {
|
||||
ev.prevent_default();
|
||||
on_reply.run(display_name.clone());
|
||||
on_dismiss.run(notif_id);
|
||||
}
|
||||
"c" | "C" => {
|
||||
ev.prevent_default();
|
||||
on_context.run(display_name.clone());
|
||||
on_dismiss.run(notif_id);
|
||||
}
|
||||
"h" | "H" => {
|
||||
ev.prevent_default();
|
||||
on_history.run(());
|
||||
on_dismiss.run(notif_id);
|
||||
}
|
||||
"Escape" => {
|
||||
ev.prevent_default();
|
||||
on_dismiss.run(notif_id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
"c" | "C" => {
|
||||
ev.prevent_default();
|
||||
on_context.run(display_name.clone());
|
||||
on_dismiss.run(notif_id);
|
||||
}
|
||||
"h" | "H" => {
|
||||
ev.prevent_default();
|
||||
on_history.run(());
|
||||
on_dismiss.run(notif_id);
|
||||
}
|
||||
"Escape" => {
|
||||
ev.prevent_default();
|
||||
on_dismiss.run(notif_id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
if let Some(window) = web_sys::window() {
|
||||
let _ = window.add_event_listener_with_callback(
|
||||
"keydown",
|
||||
closure.as_ref().unchecked_ref(),
|
||||
);
|
||||
let _ = window
|
||||
.add_event_listener_with_callback("keydown", closure.as_ref().unchecked_ref());
|
||||
}
|
||||
|
||||
// Store closure for cleanup on next change
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue