Compare commits
5 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c2fa499b8 | ||
|
|
f121d5b220 | ||
|
|
449227d019 | ||
|
|
bc47a4ac5c | ||
|
|
a3bf33aee4 |
@@ -6,7 +6,7 @@ mod push;
|
||||
mod rate_limit;
|
||||
mod sse;
|
||||
|
||||
use shared::{scgi, xmlrpc};
|
||||
use shared::xmlrpc;
|
||||
|
||||
use axum::error_handling::HandleErrorLayer;
|
||||
use axum::{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
pub mod context_menu;
|
||||
pub mod layout;
|
||||
pub mod modal;
|
||||
pub mod toast;
|
||||
pub mod torrent;
|
||||
pub mod auth;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
use leptos::prelude::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[component]
|
||||
pub fn Modal(
|
||||
#[prop(into)] title: String,
|
||||
children: ChildrenFn,
|
||||
#[prop(into)] on_confirm: Callback<()>,
|
||||
#[prop(into)] on_cancel: Callback<()>,
|
||||
#[prop(into)] visible: Signal<bool>,
|
||||
#[prop(into, default = "Confirm".to_string())] confirm_text: String,
|
||||
#[prop(into, default = "Cancel".to_string())] cancel_text: String,
|
||||
#[prop(into, default = false)] is_danger: bool,
|
||||
) -> impl IntoView {
|
||||
let title = StoredValue::new_local(title);
|
||||
let on_confirm = StoredValue::new_local(on_confirm);
|
||||
let on_cancel = StoredValue::new_local(on_cancel);
|
||||
let confirm_text = StoredValue::new_local(confirm_text);
|
||||
let cancel_text = StoredValue::new_local(cancel_text);
|
||||
|
||||
view! {
|
||||
<Show when=move || visible.get() fallback=|| ()>
|
||||
<div class="fixed inset-0 bg-background/80 backdrop-blur-sm flex items-end md:items-center justify-center z-[200] animate-in fade-in duration-200 sm:p-4">
|
||||
<div class="bg-card p-6 rounded-t-2xl md:rounded-lg w-full max-w-sm shadow-xl border border-border ring-0 transform transition-all animate-in slide-in-from-bottom-10 md:slide-in-from-bottom-0 md:zoom-in-95">
|
||||
<h3 class="text-lg font-semibold text-card-foreground mb-4">{move || title.get_value()}</h3>
|
||||
|
||||
<div class="text-muted-foreground mb-6 text-sm">
|
||||
{children()}
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-3">
|
||||
<button
|
||||
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2"
|
||||
on:click=move |_| on_cancel.with_value(|cb| cb.run(()))
|
||||
>
|
||||
{move || cancel_text.get_value()}
|
||||
</button>
|
||||
<button
|
||||
class=move || crate::utils::cn(format!("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2 {}",
|
||||
if is_danger { "bg-destructive text-destructive-foreground hover:bg-destructive/90" }
|
||||
else { "bg-primary text-primary-foreground hover:bg-primary/90" }
|
||||
))
|
||||
on:click=move |_| {
|
||||
log::info!("Modal: Confirm clicked");
|
||||
on_confirm.with_value(|cb| cb.run(()))
|
||||
}
|
||||
>
|
||||
{move || confirm_text.get_value()}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Show>
|
||||
}
|
||||
}
|
||||
@@ -107,11 +107,24 @@ pub fn provide_torrent_store() {
|
||||
let store = TorrentStore { torrents, filter, search_query, global_stats, notifications, user };
|
||||
provide_context(store);
|
||||
|
||||
// SSE Connection
|
||||
Effect::new(move |_| {
|
||||
if user.get().is_none() { return; }
|
||||
let notifications_for_effect = notifications;
|
||||
let global_stats_for_effect = global_stats;
|
||||
let torrents_for_effect = torrents;
|
||||
let show_browser_notification = show_browser_notification.clone();
|
||||
|
||||
Effect::new(move |_| {
|
||||
let user_val = user.get();
|
||||
if user_val.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let notifications = notifications_for_effect;
|
||||
let global_stats = global_stats_for_effect;
|
||||
let torrents = torrents_for_effect;
|
||||
let show_browser_notification = show_browser_notification.clone();
|
||||
|
||||
log::info!("SSE: Starting connection (user logged in)");
|
||||
|
||||
leptos::task::spawn_local(async move {
|
||||
let mut backoff_ms: u32 = 1000;
|
||||
let mut was_connected = false;
|
||||
|
||||
Reference in New Issue
Block a user