fix: resolve syntax error and restore sidebar content in sidebar.rs
Some checks failed
Build MIPS Binary / build (push) Failing after 37s
Some checks failed
Build MIPS Binary / build (push) Failing after 37s
This commit is contained in:
@@ -8,9 +8,64 @@ use crate::components::ui::switch::Switch;
|
|||||||
#[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");
|
||||||
|
|
||||||
// ... (existing counts and logic)
|
let total_count = move || store.torrents.with(|map| map.len());
|
||||||
|
let downloading_count = move || {
|
||||||
|
store.torrents.with(|map| {
|
||||||
|
map.values()
|
||||||
|
.filter(|t| t.status == shared::TorrentStatus::Downloading)
|
||||||
|
.count()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
let seeding_count = move || {
|
||||||
|
store.torrents.with(|map| {
|
||||||
|
map.values()
|
||||||
|
.filter(|t| t.status == shared::TorrentStatus::Seeding)
|
||||||
|
.count()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
let completed_count = move || {
|
||||||
|
store.torrents.with(|map| {
|
||||||
|
map.values()
|
||||||
|
.filter(|t| {
|
||||||
|
t.status == shared::TorrentStatus::Seeding
|
||||||
|
|| (t.status == shared::TorrentStatus::Paused && t.percent_complete >= 100.0)
|
||||||
|
})
|
||||||
|
.count()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
let paused_count = move || {
|
||||||
|
store.torrents.with(|map| {
|
||||||
|
map.values()
|
||||||
|
.filter(|t| t.status == shared::TorrentStatus::Paused)
|
||||||
|
.count()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
let inactive_count = move || {
|
||||||
|
store.torrents.with(|map| {
|
||||||
|
map.values()
|
||||||
|
.filter(|t| {
|
||||||
|
t.status == shared::TorrentStatus::Paused
|
||||||
|
|| t.status == shared::TorrentStatus::Error
|
||||||
|
})
|
||||||
|
.count()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let set_filter = move |f: crate::store::FilterStatus| {
|
||||||
|
store.filter.set(f);
|
||||||
|
};
|
||||||
|
|
||||||
|
let is_active = move |f: crate::store::FilterStatus| store.filter.get() == f;
|
||||||
|
|
||||||
|
let username = move || {
|
||||||
|
store.user.get().unwrap_or_else(|| "User".to_string())
|
||||||
|
};
|
||||||
|
|
||||||
|
let first_letter = move || {
|
||||||
|
username().chars().next().unwrap_or('?').to_uppercase().to_string()
|
||||||
|
};
|
||||||
|
|
||||||
let on_push_toggle = move |checked: bool| {
|
let on_push_toggle = move |checked: bool| {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
if checked {
|
if checked {
|
||||||
@@ -26,11 +81,69 @@ pub fn Sidebar() -> impl IntoView {
|
|||||||
|
|
||||||
view! {
|
view! {
|
||||||
<SidenavHeader>
|
<SidenavHeader>
|
||||||
// ... (VibeTorrent Header)
|
<div class="flex items-center gap-2 px-2 py-4">
|
||||||
|
<div class="flex size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground shadow-sm">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.362 5.214A8.252 8.252 0 0112 21 8.25 8.25 0 016.038 7.048 8.287 8.287 0 009 9.6a8.983 8.983 0 013.361-6.867 8.21 8.25 0 003 2.48z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="grid flex-1 text-left text-sm leading-tight overflow-hidden">
|
||||||
|
<span class="truncate font-semibold text-foreground text-base">"VibeTorrent"</span>
|
||||||
|
<span class="truncate text-[10px] text-muted-foreground opacity-70">"v3.0.0"</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</SidenavHeader>
|
</SidenavHeader>
|
||||||
|
|
||||||
<SidenavContent>
|
<SidenavContent>
|
||||||
// ... (Filters)
|
<SidenavGroup>
|
||||||
|
<SidenavGroupLabel>"Filtreler"</SidenavGroupLabel>
|
||||||
|
<SidenavGroupContent>
|
||||||
|
<SidenavMenu>
|
||||||
|
<SidebarItem
|
||||||
|
active=Signal::derive(move || is_active(crate::store::FilterStatus::All))
|
||||||
|
on_click=move |_| set_filter(crate::store::FilterStatus::All)
|
||||||
|
icon="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"
|
||||||
|
label="Tümü"
|
||||||
|
count=Signal::derive(total_count)
|
||||||
|
/>
|
||||||
|
<SidebarItem
|
||||||
|
active=Signal::derive(move || is_active(crate::store::FilterStatus::Downloading))
|
||||||
|
on_click=move |_| set_filter(crate::store::FilterStatus::Downloading)
|
||||||
|
icon="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"
|
||||||
|
label="İndirilenler"
|
||||||
|
count=Signal::derive(downloading_count)
|
||||||
|
/>
|
||||||
|
<SidebarItem
|
||||||
|
active=Signal::derive(move || is_active(crate::store::FilterStatus::Seeding))
|
||||||
|
on_click=move |_| set_filter(crate::store::FilterStatus::Seeding)
|
||||||
|
icon="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"
|
||||||
|
label="Gönderilenler"
|
||||||
|
count=Signal::derive(seeding_count)
|
||||||
|
/>
|
||||||
|
<SidebarItem
|
||||||
|
active=Signal::derive(move || is_active(crate::store::FilterStatus::Completed))
|
||||||
|
on_click=move |_| set_filter(crate::store::FilterStatus::Completed)
|
||||||
|
icon="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||||
|
label="Tamamlananlar"
|
||||||
|
count=Signal::derive(completed_count)
|
||||||
|
/>
|
||||||
|
<SidebarItem
|
||||||
|
active=Signal::derive(move || is_active(crate::store::FilterStatus::Paused))
|
||||||
|
on_click=move |_| set_filter(crate::store::FilterStatus::Paused)
|
||||||
|
icon="M15.75 5.25v13.5m-7.5-13.5v13.5"
|
||||||
|
label="Durdurulanlar"
|
||||||
|
count=Signal::derive(paused_count)
|
||||||
|
/>
|
||||||
|
<SidebarItem
|
||||||
|
active=Signal::derive(move || is_active(crate::store::FilterStatus::Inactive))
|
||||||
|
on_click=move |_| set_filter(crate::store::FilterStatus::Inactive)
|
||||||
|
icon="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"
|
||||||
|
label="Pasif"
|
||||||
|
count=Signal::derive(inactive_count)
|
||||||
|
/>
|
||||||
|
</SidenavMenu>
|
||||||
|
</SidenavGroupContent>
|
||||||
|
</SidenavGroup>
|
||||||
</SidenavContent>
|
</SidenavContent>
|
||||||
|
|
||||||
<SidenavFooter class="p-4 space-y-4">
|
<SidenavFooter class="p-4 space-y-4">
|
||||||
@@ -80,8 +193,6 @@ pub fn Sidebar() -> impl IntoView {
|
|||||||
</SidenavFooter>
|
</SidenavFooter>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn SidebarItem(
|
fn SidebarItem(
|
||||||
|
|||||||
Reference in New Issue
Block a user