From 88e908813fcfb40e841679a5ea2b592526e822b3 Mon Sep 17 00:00:00 2001 From: hrzlgnm Date: Tue, 17 Dec 2024 22:42:11 +0100 Subject: [PATCH] feat: only show toast about copied text on desktop plaforms (#627) --- src/app.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index 69dab9c..750c1cf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -355,6 +355,9 @@ fn CopyToClipBoardButton( button_text: Option, #[prop(optional, into)] disabled: MaybeSignal, ) -> impl IntoView { + let is_desktop = use_context::() + .expect("is_desktop context to exist") + .0; let (text_to_copy, _) = create_signal(text.clone().unwrap_or_default()); let copy_to_clipboard_action = create_action(|input: &String| { let input = input.clone(); @@ -364,10 +367,12 @@ fn CopyToClipBoardButton( let on_copy_to_clipboard_click = move |_| { let text = text_to_copy.get_untracked(); copy_to_clipboard_action.dispatch(text.clone()); - show_toast(ToastOptions { - message: format!("Copied {} to clipboard", text), - duration: Duration::from_millis(2000), - }); + if is_desktop.get_untracked() { + show_toast(ToastOptions { + message: format!("Copied {} to clipboard", text), + duration: Duration::from_millis(2000), + }); + } }; view! {