Compare commits
15 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4fe8d065c | ||
|
|
3215b38272 | ||
|
|
8eb594e804 | ||
|
|
518af10cd7 | ||
|
|
0304c5cb7d | ||
|
|
cee609700a | ||
|
|
a9de8aeb5a | ||
|
|
79a88306c3 | ||
|
|
96ca09b9bd | ||
|
|
4d88660d91 | ||
|
|
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::{
|
||||
|
||||
@@ -25,9 +25,7 @@ pub fn App() -> impl IntoView {
|
||||
match setup_res {
|
||||
Ok(status) => {
|
||||
if !status.completed {
|
||||
log::info!("Setup not completed, redirecting to /setup");
|
||||
let navigate = use_navigate();
|
||||
navigate("/setup", Default::default());
|
||||
log::info!("Setup not completed");
|
||||
is_loading.1.set(false);
|
||||
return;
|
||||
}
|
||||
@@ -48,27 +46,12 @@ pub fn App() -> impl IntoView {
|
||||
}
|
||||
|
||||
is_authenticated.1.set(true);
|
||||
|
||||
let pathname = window().location().pathname().unwrap_or_default();
|
||||
if pathname == "/login" || pathname == "/setup" {
|
||||
log::info!("Already authenticated, redirecting to home");
|
||||
let navigate = use_navigate();
|
||||
navigate("/", Default::default());
|
||||
}
|
||||
}
|
||||
Ok(false) => {
|
||||
log::info!("Not authenticated");
|
||||
|
||||
let pathname = window().location().pathname().unwrap_or_default();
|
||||
if pathname != "/login" && pathname != "/setup" {
|
||||
let navigate = use_navigate();
|
||||
navigate("/login", Default::default());
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Auth check failed: {:?}", e);
|
||||
let navigate = use_navigate();
|
||||
navigate("/login", Default::default());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,10 +75,39 @@ pub fn App() -> impl IntoView {
|
||||
<div class="relative w-full h-screen" style="height: 100dvh;">
|
||||
<Router>
|
||||
<Routes fallback=|| view! { <div class="p-4">"404 Not Found"</div> }>
|
||||
<Route path=leptos_router::path!("/login") view=move || view! { <Login /> } />
|
||||
<Route path=leptos_router::path!("/setup") view=move || view! { <Setup /> } />
|
||||
<Route path=leptos_router::path!("/login") view=move || {
|
||||
let authenticated = is_authenticated.0.get();
|
||||
|
||||
Effect::new(move |_| {
|
||||
if authenticated {
|
||||
log::info!("Already authenticated, redirecting to home");
|
||||
let navigate = use_navigate();
|
||||
navigate("/", Default::default());
|
||||
}
|
||||
});
|
||||
|
||||
view! { <Login /> }
|
||||
} />
|
||||
<Route path=leptos_router::path!("/setup") view=move || {
|
||||
Effect::new(move |_| {
|
||||
if is_authenticated.0.get() {
|
||||
let navigate = use_navigate();
|
||||
navigate("/", Default::default());
|
||||
}
|
||||
});
|
||||
|
||||
view! { <Setup /> }
|
||||
} />
|
||||
|
||||
<Route path=leptos_router::path!("/") view=move || {
|
||||
Effect::new(move |_| {
|
||||
if !is_loading.0.get() && !is_authenticated.0.get() {
|
||||
log::info!("Not authenticated, redirecting to login");
|
||||
let navigate = use_navigate();
|
||||
navigate("/login", Default::default());
|
||||
}
|
||||
});
|
||||
|
||||
view! {
|
||||
<Show when=move || !is_loading.0.get() fallback=|| view! {
|
||||
<div class="flex items-center justify-center h-screen bg-base-100">
|
||||
@@ -112,6 +124,13 @@ pub fn App() -> impl IntoView {
|
||||
}/>
|
||||
|
||||
<Route path=leptos_router::path!("/settings") view=move || {
|
||||
Effect::new(move |_| {
|
||||
if !is_authenticated.0.get() {
|
||||
let navigate = use_navigate();
|
||||
navigate("/login", Default::default());
|
||||
}
|
||||
});
|
||||
|
||||
view! {
|
||||
<Show when=move || !is_loading.0.get() fallback=|| ()>
|
||||
<Show when=move || is_authenticated.0.get() fallback=|| ()>
|
||||
@@ -128,4 +147,4 @@ pub fn App() -> impl IntoView {
|
||||
<ToastContainer />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
}
|
||||
@@ -51,44 +51,49 @@ pub fn TorrentTable() -> impl IntoView {
|
||||
let sort_dir = signal(SortDirection::Descending);
|
||||
|
||||
let filtered_hashes = move || {
|
||||
store.torrents.with(|map| {
|
||||
let mut torrents: Vec<&shared::Torrent> = map.values().filter(|t| {
|
||||
let filter = store.filter.get();
|
||||
let search = store.search_query.get().to_lowercase();
|
||||
let matches_filter = match filter {
|
||||
crate::store::FilterStatus::All => true,
|
||||
crate::store::FilterStatus::Downloading => t.status == shared::TorrentStatus::Downloading,
|
||||
crate::store::FilterStatus::Seeding => t.status == shared::TorrentStatus::Seeding,
|
||||
crate::store::FilterStatus::Completed => t.status == shared::TorrentStatus::Seeding || (t.status == shared::TorrentStatus::Paused && t.percent_complete >= 100.0),
|
||||
crate::store::FilterStatus::Paused => t.status == shared::TorrentStatus::Paused,
|
||||
crate::store::FilterStatus::Inactive => t.status == shared::TorrentStatus::Paused || t.status == shared::TorrentStatus::Error,
|
||||
_ => true,
|
||||
};
|
||||
let matches_search = if search.is_empty() { true } else { t.name.to_lowercase().contains(&search) };
|
||||
matches_filter && matches_search
|
||||
}).collect();
|
||||
let torrents_map = store.torrents.get();
|
||||
log::debug!("TorrentTable: store.torrents has {} entries", torrents_map.len());
|
||||
|
||||
let filter = store.filter.get();
|
||||
let search = store.search_query.get();
|
||||
let search_lower = search.to_lowercase();
|
||||
|
||||
let mut torrents: Vec<&shared::Torrent> = torrents_map.values().filter(|t| {
|
||||
let matches_filter = match filter {
|
||||
crate::store::FilterStatus::All => true,
|
||||
crate::store::FilterStatus::Downloading => t.status == shared::TorrentStatus::Downloading,
|
||||
crate::store::FilterStatus::Seeding => t.status == shared::TorrentStatus::Seeding,
|
||||
crate::store::FilterStatus::Completed => t.status == shared::TorrentStatus::Seeding || (t.status == shared::TorrentStatus::Paused && t.percent_complete >= 100.0),
|
||||
crate::store::FilterStatus::Paused => t.status == shared::TorrentStatus::Paused,
|
||||
crate::store::FilterStatus::Inactive => t.status == shared::TorrentStatus::Paused || t.status == shared::TorrentStatus::Error,
|
||||
_ => true,
|
||||
};
|
||||
let matches_search = if search_lower.is_empty() { true } else { t.name.to_lowercase().contains(&search_lower) };
|
||||
matches_filter && matches_search
|
||||
}).collect();
|
||||
|
||||
torrents.sort_by(|a, b| {
|
||||
let col = sort_col.0.get();
|
||||
let dir = sort_dir.0.get();
|
||||
let cmp = match col {
|
||||
SortColumn::Name => a.name.to_lowercase().cmp(&b.name.to_lowercase()),
|
||||
SortColumn::Size => a.size.cmp(&b.size),
|
||||
SortColumn::Progress => a.percent_complete.partial_cmp(&b.percent_complete).unwrap_or(std::cmp::Ordering::Equal),
|
||||
SortColumn::Status => format!("{:?}", a.status).cmp(&format!("{:?}", b.status)),
|
||||
SortColumn::DownSpeed => a.down_rate.cmp(&b.down_rate),
|
||||
SortColumn::UpSpeed => a.up_rate.cmp(&b.up_rate),
|
||||
SortColumn::ETA => {
|
||||
let a_eta = if a.eta <= 0 { i64::MAX } else { a.eta };
|
||||
let b_eta = if b.eta <= 0 { i64::MAX } else { b.eta };
|
||||
a_eta.cmp(&b_eta)
|
||||
}
|
||||
SortColumn::AddedDate => a.added_date.cmp(&b.added_date),
|
||||
};
|
||||
if dir == SortDirection::Descending { cmp.reverse() } else { cmp }
|
||||
});
|
||||
torrents.into_iter().map(|t| t.hash.clone()).collect::<Vec<String>>()
|
||||
})
|
||||
log::debug!("TorrentTable: {} torrents after filtering", torrents.len());
|
||||
|
||||
torrents.sort_by(|a, b| {
|
||||
let col = sort_col.0.get();
|
||||
let dir = sort_dir.0.get();
|
||||
let cmp = match col {
|
||||
SortColumn::Name => a.name.to_lowercase().cmp(&b.name.to_lowercase()),
|
||||
SortColumn::Size => a.size.cmp(&b.size),
|
||||
SortColumn::Progress => a.percent_complete.partial_cmp(&b.percent_complete).unwrap_or(std::cmp::Ordering::Equal),
|
||||
SortColumn::Status => format!("{:?}", a.status).cmp(&format!("{:?}", b.status)),
|
||||
SortColumn::DownSpeed => a.down_rate.cmp(&b.down_rate),
|
||||
SortColumn::UpSpeed => a.up_rate.cmp(&b.up_rate),
|
||||
SortColumn::ETA => {
|
||||
let a_eta = if a.eta <= 0 { i64::MAX } else { a.eta };
|
||||
let b_eta = if b.eta <= 0 { i64::MAX } else { b.eta };
|
||||
a_eta.cmp(&b_eta)
|
||||
}
|
||||
SortColumn::AddedDate => a.added_date.cmp(&b.added_date),
|
||||
};
|
||||
if dir == SortDirection::Descending { cmp.reverse() } else { cmp }
|
||||
});
|
||||
torrents.into_iter().map(|t| t.hash.clone()).collect::<Vec<String>>()
|
||||
};
|
||||
|
||||
let handle_sort = move |col: SortColumn| {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use futures::StreamExt;
|
||||
use gloo_net::eventsource::futures::EventSource;
|
||||
use leptos::prelude::*;
|
||||
use leptos::task::spawn_local;
|
||||
use shared::{AppEvent, GlobalStats, NotificationLevel, SystemNotification, Torrent};
|
||||
use std::collections::HashMap;
|
||||
use serde::{Serialize, Deserialize};
|
||||
@@ -11,10 +12,6 @@ pub struct NotificationItem {
|
||||
pub notification: SystemNotification,
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Toast Helper Functions
|
||||
// ============================================================================
|
||||
|
||||
pub fn show_toast_with_signal(
|
||||
notifications: RwSignal<Vec<NotificationItem>>,
|
||||
level: NotificationLevel,
|
||||
@@ -29,7 +26,6 @@ pub fn show_toast_with_signal(
|
||||
|
||||
notifications.update(|list| list.push(item));
|
||||
|
||||
// Auto-remove after 5 seconds
|
||||
leptos::prelude::set_timeout(
|
||||
move || {
|
||||
notifications.update(|list| list.retain(|i| i.id != id));
|
||||
@@ -47,10 +43,6 @@ pub fn show_toast(level: NotificationLevel, message: impl Into<String>) {
|
||||
pub fn toast_success(message: impl Into<String>) { show_toast(NotificationLevel::Success, message); }
|
||||
pub fn toast_error(message: impl Into<String>) { show_toast(NotificationLevel::Error, message); }
|
||||
|
||||
// ============================================================================
|
||||
// Action Message Mapping
|
||||
// ============================================================================
|
||||
|
||||
pub fn get_action_messages(action: &str) -> (&'static str, &'static str) {
|
||||
match action {
|
||||
"start" => ("Torrent başlatıldı", "Torrent başlatılamadı"),
|
||||
@@ -75,10 +67,6 @@ pub struct PushKeys {
|
||||
pub auth: String,
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Store Definition
|
||||
// ============================================================================
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum FilterStatus {
|
||||
All, Downloading, Seeding, Completed, Paused, Inactive, Active, Error,
|
||||
@@ -107,89 +95,105 @@ 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 user_for_sse = user;
|
||||
let notifications_for_sse = notifications;
|
||||
let global_stats_for_sse = global_stats;
|
||||
let torrents_for_sse = torrents;
|
||||
let show_browser_notification = show_browser_notification.clone();
|
||||
|
||||
let show_browser_notification = show_browser_notification.clone();
|
||||
leptos::task::spawn_local(async move {
|
||||
let mut backoff_ms: u32 = 1000;
|
||||
let mut was_connected = false;
|
||||
let mut disconnect_notified = false;
|
||||
spawn_local(async move {
|
||||
let mut backoff_ms: u32 = 1000;
|
||||
let mut was_connected = false;
|
||||
let mut disconnect_notified = false;
|
||||
|
||||
loop {
|
||||
let es_result = EventSource::new("/api/events");
|
||||
match es_result {
|
||||
Ok(mut es) => {
|
||||
if let Ok(mut stream) = es.subscribe("message") {
|
||||
let mut got_first_message = false;
|
||||
while let Some(Ok((_, msg))) = stream.next().await {
|
||||
if !got_first_message {
|
||||
got_first_message = true;
|
||||
backoff_ms = 1000;
|
||||
if was_connected && disconnect_notified {
|
||||
show_toast_with_signal(notifications, NotificationLevel::Success, "Sunucu bağlantısı yeniden kuruldu");
|
||||
disconnect_notified = false;
|
||||
}
|
||||
was_connected = true;
|
||||
loop {
|
||||
let user_val = user_for_sse.get();
|
||||
log::debug!("SSE: user = {:?}", user_val);
|
||||
if user_val.is_none() {
|
||||
log::debug!("SSE: User not authenticated, waiting...");
|
||||
gloo_timers::future::TimeoutFuture::new(1000).await;
|
||||
continue;
|
||||
}
|
||||
|
||||
log::debug!("SSE: Creating EventSource...");
|
||||
let es_result = EventSource::new("/api/events");
|
||||
match es_result {
|
||||
Ok(mut es) => {
|
||||
log::debug!("SSE: EventSource created, subscribing...");
|
||||
if let Ok(mut stream) = es.subscribe("message") {
|
||||
log::debug!("SSE: Subscribed to message channel");
|
||||
let mut got_first_message = false;
|
||||
while let Some(Ok((_, msg))) = stream.next().await {
|
||||
log::debug!("SSE: Received message");
|
||||
if !got_first_message {
|
||||
got_first_message = true;
|
||||
backoff_ms = 1000;
|
||||
if was_connected && disconnect_notified {
|
||||
show_toast_with_signal(notifications_for_sse, NotificationLevel::Success, "Sunucu bağlantısı yeniden kuruldu");
|
||||
disconnect_notified = false;
|
||||
}
|
||||
was_connected = true;
|
||||
}
|
||||
|
||||
if let Some(data_str) = msg.data().as_string() {
|
||||
if let Ok(event) = serde_json::from_str::<AppEvent>(&data_str) {
|
||||
match event {
|
||||
AppEvent::FullList { torrents: list, .. } => {
|
||||
torrents.update(|map| {
|
||||
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
|
||||
map.retain(|hash, _| new_hashes.contains(hash));
|
||||
for new_torrent in list {
|
||||
map.insert(new_torrent.hash.clone(), new_torrent);
|
||||
}
|
||||
});
|
||||
}
|
||||
AppEvent::Update(update) => {
|
||||
torrents.update(|map| {
|
||||
if let Some(t) = map.get_mut(&update.hash) {
|
||||
if let Some(v) = update.name { t.name = v; }
|
||||
if let Some(v) = update.size { t.size = v; }
|
||||
if let Some(v) = update.down_rate { t.down_rate = v; }
|
||||
if let Some(v) = update.up_rate { t.up_rate = v; }
|
||||
if let Some(v) = update.percent_complete { t.percent_complete = v; }
|
||||
if let Some(v) = update.completed { t.completed = v; }
|
||||
if let Some(v) = update.eta { t.eta = v; }
|
||||
if let Some(v) = update.status { t.status = v; }
|
||||
if let Some(v) = update.error_message { t.error_message = v; }
|
||||
if let Some(v) = update.label { t.label = Some(v); }
|
||||
}
|
||||
});
|
||||
}
|
||||
AppEvent::Stats(stats) => { global_stats.set(stats); }
|
||||
AppEvent::Notification(n) => {
|
||||
show_toast_with_signal(notifications, n.level.clone(), n.message.clone());
|
||||
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
|
||||
show_browser_notification("VibeTorrent", &n.message);
|
||||
if let Some(data_str) = msg.data().as_string() {
|
||||
log::debug!("SSE: Parsing JSON: {}", data_str);
|
||||
if let Ok(event) = serde_json::from_str::<AppEvent>(&data_str) {
|
||||
match event {
|
||||
AppEvent::FullList { torrents: list, .. } => {
|
||||
log::info!("SSE: Received FullList with {} torrents", list.len());
|
||||
torrents_for_sse.update(|map| {
|
||||
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
|
||||
map.retain(|hash, _| new_hashes.contains(hash));
|
||||
for new_torrent in list {
|
||||
map.insert(new_torrent.hash.clone(), new_torrent);
|
||||
}
|
||||
});
|
||||
log::debug!("SSE: torrents map now has {} entries", torrents_for_sse.with(|m| m.len()));
|
||||
}
|
||||
AppEvent::Update(update) => {
|
||||
torrents_for_sse.update(|map| {
|
||||
if let Some(t) = map.get_mut(&update.hash) {
|
||||
if let Some(v) = update.name { t.name = v; }
|
||||
if let Some(v) = update.size { t.size = v; }
|
||||
if let Some(v) = update.down_rate { t.down_rate = v; }
|
||||
if let Some(v) = update.up_rate { t.up_rate = v; }
|
||||
if let Some(v) = update.percent_complete { t.percent_complete = v; }
|
||||
if let Some(v) = update.completed { t.completed = v; }
|
||||
if let Some(v) = update.eta { t.eta = v; }
|
||||
if let Some(v) = update.status { t.status = v; }
|
||||
if let Some(v) = update.error_message { t.error_message = v; }
|
||||
if let Some(v) = update.label { t.label = Some(v); }
|
||||
}
|
||||
});
|
||||
}
|
||||
AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); }
|
||||
AppEvent::Notification(n) => {
|
||||
show_toast_with_signal(notifications_for_sse, n.level.clone(), n.message.clone());
|
||||
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
|
||||
show_browser_notification("VibeTorrent", &n.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if was_connected && !disconnect_notified {
|
||||
show_toast_with_signal(notifications, NotificationLevel::Warning, "Sunucu bağlantısı kesildi, yeniden bağlanılıyor...");
|
||||
disconnect_notified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
if was_connected && !disconnect_notified {
|
||||
show_toast_with_signal(notifications, NotificationLevel::Warning, "Sunucu bağlantısı kurulamıyor...");
|
||||
show_toast_with_signal(notifications_for_sse, NotificationLevel::Warning, "Sunucu bağlantısı kesildi, yeniden bağlanılıyor...");
|
||||
disconnect_notified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
gloo_timers::future::TimeoutFuture::new(backoff_ms).await;
|
||||
backoff_ms = std::cmp::min(backoff_ms * 2, 30000);
|
||||
Err(_) => {
|
||||
if was_connected && !disconnect_notified {
|
||||
show_toast_with_signal(notifications_for_sse, NotificationLevel::Warning, "Sunucu bağlantısı kurulamıyor...");
|
||||
disconnect_notified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
log::debug!("SSE: Reconnecting in {}ms...", backoff_ms);
|
||||
gloo_timers::future::TimeoutFuture::new(backoff_ms).await;
|
||||
backoff_ms = std::cmp::min(backoff_ms * 2, 30000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user