From e45ec46793f9c2afd4156a216688efc977186976 Mon Sep 17 00:00:00 2001 From: spinline Date: Fri, 13 Feb 2026 13:41:46 +0300 Subject: [PATCH] feat: replace legacy hold-to-delete logic with modern ButtonAction component --- frontend/src/components/context_menu.rs | 105 +++++++++------------ frontend/src/components/ui/context_menu.rs | 68 +------------ 2 files changed, 47 insertions(+), 126 deletions(-) diff --git a/frontend/src/components/context_menu.rs b/frontend/src/components/context_menu.rs index 382ba7b..91be433 100644 --- a/frontend/src/components/context_menu.rs +++ b/frontend/src/components/context_menu.rs @@ -1,5 +1,9 @@ use leptos::prelude::*; -use crate::components::ui::context_menu::*; +use crate::components::ui::context_menu::{ + ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger, +}; +use crate::components::ui::button_action::ButtonAction; +use crate::components::ui::button::ButtonVariant; #[component] pub fn TorrentContextMenu( @@ -7,72 +11,55 @@ pub fn TorrentContextMenu( torrent_hash: String, on_action: Callback<(String, String)>, ) -> impl IntoView { - let hash = StoredValue::new(torrent_hash); + let hash_c1 = torrent_hash.clone(); + let hash_c2 = torrent_hash.clone(); + let hash_c3 = torrent_hash.clone(); + let hash_c4 = torrent_hash.clone(); - let menu_action = move |action: &'static str| { - on_action.run((action.to_string(), hash.get_value())); - }; + let on_action_stored = StoredValue::new(on_action); view! { {children()} - - - - - - - "Start" - + + + "Başlat" + + + "Durdur" + + +
+ + // --- Modern Hold-to-Action Buttons --- +
+ + "Sil (Basılı Tut)" + - - - - - "Stop" - - - - - - - "Recheck" - - -
- - - - - - "Remove" - - - - - - - "Remove with Data" - "Hold" - + + "Verilerle Sil (Basılı Tut)" + +
} -} \ No newline at end of file +} diff --git a/frontend/src/components/ui/context_menu.rs b/frontend/src/components/ui/context_menu.rs index f303c17..42c1978 100644 --- a/frontend/src/components/ui/context_menu.rs +++ b/frontend/src/components/ui/context_menu.rs @@ -78,72 +78,6 @@ pub fn ContextMenuAction( } } -#[component] -pub fn ContextMenuHoldAction( - children: Children, - #[prop(into)] on_hold_complete: Callback<()>, - #[prop(optional, into)] class: String, - #[prop(default = 1000)] hold_duration: u64, -) -> impl IntoView { - let is_holding = RwSignal::new(false); - - let on_mousedown = move |_| { - is_holding.set(true); - }; - - let on_mouseup = move |_| { - is_holding.set(false); - }; - - Effect::new(move |_| { - if is_holding.get() { - leptos::task::spawn_local(async move { - gloo_timers::future::TimeoutFuture::new(hold_duration as u32).await; - if is_holding.get_untracked() { - on_hold_complete.run(()); - is_holding.set(false); - close_context_menu(); - } - }); - } - }); - - let class = tw_merge!( - "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors overflow-hidden", - class - ); - - view! { - -
- // Progress background - -
- - - - {children()} - -
- }.into_any() -} - #[derive(Clone)] struct ContextMenuContext { target_id: String, @@ -393,7 +327,7 @@ pub fn ContextMenuContent( target_id_for_script, )} - }.into_any() + } } #[component]