diff --git a/backend/src/handlers/mod.rs b/backend/src/handlers/mod.rs index 2cd4ecd..ff29d3b 100644 --- a/backend/src/handlers/mod.rs +++ b/backend/src/handlers/mod.rs @@ -85,24 +85,12 @@ pub async fn add_torrent_handler( tracing::error!("rTorrent returned fault: {}", response); return StatusCode::INTERNAL_SERVER_ERROR; } - let _ = - state - .event_bus - .send(shared::AppEvent::Notification(shared::SystemNotification { - level: shared::NotificationLevel::Success, - message: "Torrent added successfully".to_string(), - })); + // Note: Frontend shows its own toast, no SSE notification needed StatusCode::OK } Err(e) => { tracing::error!("Failed to add torrent: {}", e); - let _ = - state - .event_bus - .send(shared::AppEvent::Notification(shared::SystemNotification { - level: shared::NotificationLevel::Error, - message: format!("Failed to add torrent: {}", e), - })); + // Note: Frontend shows its own toast, no SSE notification needed StatusCode::INTERNAL_SERVER_ERROR } } @@ -136,12 +124,7 @@ pub async fn handle_torrent_action( if payload.action == "delete_with_data" { return match delete_torrent_with_data(&client, &payload.hash).await { Ok(msg) => { - let _ = state.event_bus.send(shared::AppEvent::Notification( - shared::SystemNotification { - level: shared::NotificationLevel::Success, - message: format!("Torrent deleted with data: {}", payload.hash), - }, - )); + // Note: Frontend shows its own toast (StatusCode::OK, msg).into_response() } Err((status, msg)) => (status, msg).into_response(), @@ -159,13 +142,7 @@ pub async fn handle_torrent_action( match client.call(method, ¶ms).await { Ok(_) => { - let _ = - state - .event_bus - .send(shared::AppEvent::Notification(shared::SystemNotification { - level: shared::NotificationLevel::Info, - message: format!("Action '{}' executed on torrent", payload.action), - })); + // Note: Frontend shows its own toast, no SSE notification needed (StatusCode::OK, "Action executed").into_response() } Err(e) => { diff --git a/frontend/src/components/toast.rs b/frontend/src/components/toast.rs index 012a520..000a3bb 100644 --- a/frontend/src/components/toast.rs +++ b/frontend/src/components/toast.rs @@ -2,35 +2,9 @@ use leptos::*; use shared::NotificationLevel; // ============================================================================ -// Toast Icons (Clean Code: Separation of Concerns) +// Toast Components - DaisyUI Alert Style // ============================================================================ -/// Returns the appropriate SVG icon for the notification level -fn get_toast_icon(level: &NotificationLevel) -> impl IntoView { - match level { - NotificationLevel::Info => view! { - - - - }.into_view(), - NotificationLevel::Success => view! { - - - - }.into_view(), - NotificationLevel::Warning => view! { - - - - }.into_view(), - NotificationLevel::Error => view! { - - - - }.into_view(), - } -} - /// Returns the DaisyUI alert class for the notification level fn get_alert_class(level: &NotificationLevel) -> &'static str { match level { @@ -41,10 +15,6 @@ fn get_alert_class(level: &NotificationLevel) -> &'static str { } } -// ============================================================================ -// Toast Components (Clean Code: Single Responsibility) -// ============================================================================ - /// Individual toast item component #[component] fn ToastItem( @@ -53,13 +23,20 @@ fn ToastItem( ) -> impl IntoView { let alert_class = get_alert_class(&level); + let icon = match level { + NotificationLevel::Info => "ℹ️", + NotificationLevel::Success => "✓", + NotificationLevel::Warning => "⚠️", + NotificationLevel::Error => "✕", + }; + view! { -
- {get_toast_icon(&level)} - {message} +
+ {icon} + {message}
} } @@ -71,22 +48,19 @@ pub fn ToastContainer() -> impl IntoView { let notifications = store.notifications; view! { - // Fixed to viewport with explicit inset values for reliable positioning
- -
+ } } />