- // Toolbar
"Torrents"
- // Sort Dropdown
impl IntoView {
(SortColumn::ETA, "ETA"),
];
- // Helper to close dropdown using the same logic as statusbar
let close_dropdown = move || {
if let Some(doc) = web_sys::window().and_then(|w| w.document()) {
if let Some(active) = doc.active_element() {
@@ -358,7 +350,6 @@ pub fn TorrentTable() -> impl IntoView {
- // Scrollable Content
{move || filtered_torrents().into_iter().map(|t| {
let progress_class = if t.percent_complete >= 100.0 { "progress-success" } else { "progress-primary" };
@@ -371,10 +362,8 @@ pub fn TorrentTable() -> impl IntoView {
_ => "badge-ghost"
};
let t_hash = t.hash.clone();
- // We don't need t_hash_click separately if we use t_hash, but existing pattern uses clones
let t_hash_click = t.hash.clone();
- // Long press logic
let (timer_id, set_timer_id) = create_signal(Option::::None);
let t_hash_long = t.hash.clone();
@@ -388,12 +377,7 @@ pub fn TorrentTable() -> impl IntoView {
let handle_touchstart = {
let t_hash = t_hash_long.clone();
move |e: web_sys::TouchEvent| {
- // Don't prevent default immediately, or we can't scroll.
- // But for long press, we might need to if we want to stop iOS menu.
- // -webkit-touch-callout: none (in CSS) handles the iOS menu suppression usually.
-
clear_timer();
-
if let Some(touch) = e.touches().get(0) {
let x = touch.client_x();
let y = touch.client_y();
@@ -403,8 +387,6 @@ pub fn TorrentTable() -> impl IntoView {
set_menu_position.set((x, y));
set_selected_hash.set(Some(hash.clone()));
set_menu_visible.set(true);
-
- // Haptic feedback if available
let navigator = window().navigator();
let _ = navigator.vibrate_with_duration(50);
}) as Box);
@@ -412,21 +394,17 @@ pub fn TorrentTable() -> impl IntoView {
let id = window()
.set_timeout_with_callback_and_timeout_and_arguments_0(
closure.as_ref().unchecked_ref(),
- 600 // 600ms long press
+ 600
)
.unwrap_or(0);
- closure.forget(); // Leak memory? effectively yes, but for a simplified timeout it's "okay" in this context or we need to store the closure key.
- // In a real app we might want to store the closure to drop it, but `set_timeout` takes a function pointer effectively.
- // Actually, `closure.forget()` is standard for one-off callbacks that the JS side consumes.
-
+ closure.forget();
set_timer_id.set(Some(id));
}
}
};
let handle_touchmove = move |_| {
- // If moving, it's likely a scroll, so cancel the long press
clear_timer();
};
@@ -441,7 +419,6 @@ pub fn TorrentTable() -> impl IntoView {
}
style="user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;"
on:contextmenu={
- // Fallback for desktop/mouse right click still works
let t_hash = t.hash.clone();
move |e: web_sys::MouseEvent| handle_context_menu(e, t_hash.clone())
}
@@ -489,6 +466,7 @@ pub fn TorrentTable() -> impl IntoView {
}
}).collect::>()}
+