fix(logic): exclude incomplete paused torrents from completed filter
This commit is contained in:
@@ -1,15 +1,49 @@
|
|||||||
use leptos::*;
|
|
||||||
use leptos::wasm_bindgen::JsCast;
|
use leptos::wasm_bindgen::JsCast;
|
||||||
|
use leptos::*;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Sidebar() -> impl IntoView {
|
pub fn Sidebar() -> impl IntoView {
|
||||||
let store = use_context::<crate::store::TorrentStore>().expect("store not provided");
|
let store = use_context::<crate::store::TorrentStore>().expect("store not provided");
|
||||||
|
|
||||||
let total_count = move || store.torrents.get().len();
|
let total_count = move || store.torrents.get().len();
|
||||||
let downloading_count = move || store.torrents.get().iter().filter(|t| t.status == shared::TorrentStatus::Downloading).count();
|
let downloading_count = move || {
|
||||||
let seeding_count = move || store.torrents.get().iter().filter(|t| t.status == shared::TorrentStatus::Seeding).count();
|
store
|
||||||
let completed_count = move || store.torrents.get().iter().filter(|t| t.status == shared::TorrentStatus::Seeding || t.status == shared::TorrentStatus::Paused).count();
|
.torrents
|
||||||
let inactive_count = move || store.torrents.get().iter().filter(|t| t.status == shared::TorrentStatus::Paused || t.status == shared::TorrentStatus::Error).count();
|
.get()
|
||||||
|
.iter()
|
||||||
|
.filter(|t| t.status == shared::TorrentStatus::Downloading)
|
||||||
|
.count()
|
||||||
|
};
|
||||||
|
let seeding_count = move || {
|
||||||
|
store
|
||||||
|
.torrents
|
||||||
|
.get()
|
||||||
|
.iter()
|
||||||
|
.filter(|t| t.status == shared::TorrentStatus::Seeding)
|
||||||
|
.count()
|
||||||
|
};
|
||||||
|
let completed_count = move || {
|
||||||
|
store
|
||||||
|
.torrents
|
||||||
|
.get()
|
||||||
|
.iter()
|
||||||
|
.filter(|t| {
|
||||||
|
t.status == shared::TorrentStatus::Seeding
|
||||||
|
|| (t.status == shared::TorrentStatus::Paused && t.percent_complete >= 100.0)
|
||||||
|
})
|
||||||
|
.count()
|
||||||
|
};
|
||||||
|
let inactive_count = move || {
|
||||||
|
store
|
||||||
|
.torrents
|
||||||
|
.get()
|
||||||
|
.iter()
|
||||||
|
.filter(|t| {
|
||||||
|
t.status == shared::TorrentStatus::Paused
|
||||||
|
|| t.status == shared::TorrentStatus::Error
|
||||||
|
})
|
||||||
|
.count()
|
||||||
|
};
|
||||||
|
|
||||||
let close_drawer = move || {
|
let close_drawer = move || {
|
||||||
if let Some(element) = document().get_element_by_id("my-drawer") {
|
if let Some(element) = document().get_element_by_id("my-drawer") {
|
||||||
@@ -25,7 +59,11 @@ pub fn Sidebar() -> impl IntoView {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let filter_class = move |f: crate::store::FilterStatus| {
|
let filter_class = move |f: crate::store::FilterStatus| {
|
||||||
if store.filter.get() == f { "active" } else { "" }
|
if store.filter.get() == f {
|
||||||
|
"active"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
crate::store::FilterStatus::Completed => {
|
crate::store::FilterStatus::Completed => {
|
||||||
t.status == shared::TorrentStatus::Seeding
|
t.status == shared::TorrentStatus::Seeding
|
||||||
|| t.status == shared::TorrentStatus::Paused
|
|| (t.status == shared::TorrentStatus::Paused
|
||||||
|
&& t.percent_complete >= 100.0)
|
||||||
} // Approximate
|
} // Approximate
|
||||||
crate::store::FilterStatus::Inactive => {
|
crate::store::FilterStatus::Inactive => {
|
||||||
t.status == shared::TorrentStatus::Paused
|
t.status == shared::TorrentStatus::Paused
|
||||||
|
|||||||
Reference in New Issue
Block a user