Compare commits

...

3 Commits

Author SHA1 Message Date
spinline
79a88306c3 fix: use .get() instead of .with() for RwSignal and fix indentation
All checks were successful
Build MIPS Binary / build (push) Successful in 5m21s
2026-02-09 22:12:05 +03:00
spinline
96ca09b9bd debug: add TorrentTable logging to trace UI rendering
Some checks failed
Build MIPS Binary / build (push) Has been cancelled
2026-02-09 22:09:55 +03:00
spinline
4d88660d91 debug: add SSE logging to trace torrent loading issue
Some checks failed
Build MIPS Binary / build (push) Has been cancelled
2026-02-09 22:07:44 +03:00
2 changed files with 46 additions and 37 deletions

View File

@@ -51,44 +51,49 @@ pub fn TorrentTable() -> impl IntoView {
let sort_dir = signal(SortDirection::Descending); let sort_dir = signal(SortDirection::Descending);
let filtered_hashes = move || { let filtered_hashes = move || {
store.torrents.with(|map| { let torrents_map = store.torrents.get();
let mut torrents: Vec<&shared::Torrent> = map.values().filter(|t| { log::debug!("TorrentTable: store.torrents has {} entries", torrents_map.len());
let filter = store.filter.get();
let search = store.search_query.get().to_lowercase(); let filter = store.filter.get();
let matches_filter = match filter { let search = store.search_query.get();
crate::store::FilterStatus::All => true, let search_lower = search.to_lowercase();
crate::store::FilterStatus::Downloading => t.status == shared::TorrentStatus::Downloading,
crate::store::FilterStatus::Seeding => t.status == shared::TorrentStatus::Seeding, let mut torrents: Vec<&shared::Torrent> = torrents_map.values().filter(|t| {
crate::store::FilterStatus::Completed => t.status == shared::TorrentStatus::Seeding || (t.status == shared::TorrentStatus::Paused && t.percent_complete >= 100.0), let matches_filter = match filter {
crate::store::FilterStatus::Paused => t.status == shared::TorrentStatus::Paused, crate::store::FilterStatus::All => true,
crate::store::FilterStatus::Inactive => t.status == shared::TorrentStatus::Paused || t.status == shared::TorrentStatus::Error, crate::store::FilterStatus::Downloading => t.status == shared::TorrentStatus::Downloading,
_ => true, 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),
let matches_search = if search.is_empty() { true } else { t.name.to_lowercase().contains(&search) }; crate::store::FilterStatus::Paused => t.status == shared::TorrentStatus::Paused,
matches_filter && matches_search crate::store::FilterStatus::Inactive => t.status == shared::TorrentStatus::Paused || t.status == shared::TorrentStatus::Error,
}).collect(); _ => 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| { log::debug!("TorrentTable: {} torrents after filtering", torrents.len());
let col = sort_col.0.get();
let dir = sort_dir.0.get(); torrents.sort_by(|a, b| {
let cmp = match col { let col = sort_col.0.get();
SortColumn::Name => a.name.to_lowercase().cmp(&b.name.to_lowercase()), let dir = sort_dir.0.get();
SortColumn::Size => a.size.cmp(&b.size), let cmp = match col {
SortColumn::Progress => a.percent_complete.partial_cmp(&b.percent_complete).unwrap_or(std::cmp::Ordering::Equal), SortColumn::Name => a.name.to_lowercase().cmp(&b.name.to_lowercase()),
SortColumn::Status => format!("{:?}", a.status).cmp(&format!("{:?}", b.status)), SortColumn::Size => a.size.cmp(&b.size),
SortColumn::DownSpeed => a.down_rate.cmp(&b.down_rate), SortColumn::Progress => a.percent_complete.partial_cmp(&b.percent_complete).unwrap_or(std::cmp::Ordering::Equal),
SortColumn::UpSpeed => a.up_rate.cmp(&b.up_rate), SortColumn::Status => format!("{:?}", a.status).cmp(&format!("{:?}", b.status)),
SortColumn::ETA => { SortColumn::DownSpeed => a.down_rate.cmp(&b.down_rate),
let a_eta = if a.eta <= 0 { i64::MAX } else { a.eta }; SortColumn::UpSpeed => a.up_rate.cmp(&b.up_rate),
let b_eta = if b.eta <= 0 { i64::MAX } else { b.eta }; SortColumn::ETA => {
a_eta.cmp(&b_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 };
SortColumn::AddedDate => a.added_date.cmp(&b.added_date), a_eta.cmp(&b_eta)
}; }
if dir == SortDirection::Descending { cmp.reverse() } else { cmp } SortColumn::AddedDate => a.added_date.cmp(&b.added_date),
}); };
torrents.into_iter().map(|t| t.hash.clone()).collect::<Vec<String>>() 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| { let handle_sort = move |col: SortColumn| {

View File

@@ -114,7 +114,9 @@ pub fn provide_torrent_store() {
Effect::new(move |_| { Effect::new(move |_| {
let user_val = user.get(); let user_val = user.get();
log::debug!("SSE Effect: user = {:?}", user_val);
if user_val.is_none() { if user_val.is_none() {
log::debug!("SSE Effect: user is None, skipping connection");
return; return;
} }
@@ -151,6 +153,7 @@ pub fn provide_torrent_store() {
if let Ok(event) = serde_json::from_str::<AppEvent>(&data_str) { if let Ok(event) = serde_json::from_str::<AppEvent>(&data_str) {
match event { match event {
AppEvent::FullList { torrents: list, .. } => { AppEvent::FullList { torrents: list, .. } => {
log::debug!("SSE: Received FullList with {} torrents", list.len());
torrents.update(|map| { torrents.update(|map| {
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect(); let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
map.retain(|hash, _| new_hashes.contains(hash)); map.retain(|hash, _| new_hashes.contains(hash));
@@ -158,6 +161,7 @@ pub fn provide_torrent_store() {
map.insert(new_torrent.hash.clone(), new_torrent); map.insert(new_torrent.hash.clone(), new_torrent);
} }
}); });
log::debug!("SSE: torrents map now has {} entries", torrents.with(|m| m.len()));
} }
AppEvent::Update(update) => { AppEvent::Update(update) => {
torrents.update(|map| { torrents.update(|map| {