fix: resolve ownership (move) errors and type inference issues in torrent table component
Some checks failed
Build MIPS Binary / build (push) Failing after 34s
Some checks failed
Build MIPS Binary / build (push) Failing after 34s
This commit is contained in:
@@ -577,15 +577,11 @@ fn TorrentRow(
|
||||
{
|
||||
let on_action = on_action.clone();
|
||||
move || {
|
||||
let t = torrent.get().unwrap();
|
||||
let t_name = t.name.clone();
|
||||
|
||||
let is_active_selection = Memo::new(move |_| {
|
||||
let selected = store.selected_torrent.get();
|
||||
selected.as_deref() == Some(stored_hash.get_value().as_str())
|
||||
});
|
||||
|
||||
let t_name_stored = StoredValue::new(t_name.clone());
|
||||
let h_for_menu = stored_hash.get_value();
|
||||
|
||||
view! {
|
||||
@@ -603,25 +599,29 @@ fn TorrentRow(
|
||||
</DataTableCell>
|
||||
|
||||
{move || visible_columns.get().contains("Name").then({
|
||||
move || view! {
|
||||
<DataTableCell class="font-medium truncate max-w-[200px] lg:max-w-md" attr:title=t_name_stored.get_value()>
|
||||
{t_name_stored.get_value()}
|
||||
move || {
|
||||
let name = torrent.get().map(|t| t.name).unwrap_or_default();
|
||||
view! {
|
||||
<DataTableCell class="font-medium truncate max-w-[200px] lg:max-w-md" attr:title=name.clone()>
|
||||
{name}
|
||||
</DataTableCell>
|
||||
}
|
||||
}
|
||||
}).into_any()}
|
||||
|
||||
{move || visible_columns.get().contains("Size").then({
|
||||
let size_bytes = t.size;
|
||||
move || {
|
||||
let size_str = format_bytes(size_bytes);
|
||||
let size = torrent.get().map(|t| t.size).unwrap_or(0);
|
||||
let size_str = format_bytes(size);
|
||||
view! { <DataTableCell class="font-mono text-xs text-muted-foreground whitespace-nowrap">{size_str}</DataTableCell> }
|
||||
}
|
||||
}).into_any()}
|
||||
|
||||
{move || visible_columns.get().contains("Progress").then({
|
||||
move || {
|
||||
let t = torrent.get().unwrap();
|
||||
let percent = t.percent_complete;
|
||||
let status = t.status.clone();
|
||||
move || {
|
||||
let class = if status == shared::TorrentStatus::Error {
|
||||
"bg-destructive/20 [&>div]:bg-destructive".to_string()
|
||||
} else {
|
||||
@@ -642,6 +642,8 @@ fn TorrentRow(
|
||||
}).into_any()}
|
||||
|
||||
{move || visible_columns.get().contains("Status").then({
|
||||
move || {
|
||||
let t = torrent.get().unwrap();
|
||||
let status_text = format!("{:?}", t.status);
|
||||
let variant = match t.status {
|
||||
shared::TorrentStatus::Seeding => BadgeVariant::Success,
|
||||
@@ -650,40 +652,41 @@ fn TorrentRow(
|
||||
shared::TorrentStatus::Error => BadgeVariant::Destructive,
|
||||
_ => BadgeVariant::Secondary,
|
||||
};
|
||||
move || view! {
|
||||
view! {
|
||||
<DataTableCell class="whitespace-nowrap">
|
||||
<Badge variant=variant>{status_text.clone()}</Badge>
|
||||
<Badge variant=variant>{status_text}</Badge>
|
||||
</DataTableCell>
|
||||
}
|
||||
}
|
||||
}).into_any()}
|
||||
|
||||
{move || visible_columns.get().contains("DownSpeed").then({
|
||||
let rate = t.down_rate;
|
||||
move || {
|
||||
let rate = torrent.get().map(|t| t.down_rate).unwrap_or(0);
|
||||
let speed_str = format_speed(rate);
|
||||
view! { <DataTableCell class="text-right font-mono text-xs text-green-600 dark:text-green-500 whitespace-nowrap">{speed_str}</DataTableCell> }
|
||||
}
|
||||
}).into_any()}
|
||||
|
||||
{move || visible_columns.get().contains("UpSpeed").then({
|
||||
let rate = t.up_rate;
|
||||
move || {
|
||||
let rate = torrent.get().map(|t| t.up_rate).unwrap_or(0);
|
||||
let speed_str = format_speed(rate);
|
||||
view! { <DataTableCell class="text-right font-mono text-xs text-blue-600 dark:text-blue-500 whitespace-nowrap">{speed_str}</DataTableCell> }
|
||||
}
|
||||
}).into_any()}
|
||||
|
||||
{move || visible_columns.get().contains("ETA").then({
|
||||
let eta = t.eta;
|
||||
move || {
|
||||
let eta = torrent.get().map(|t| t.eta).unwrap_or(0);
|
||||
let eta_str = format_duration(eta);
|
||||
view! { <DataTableCell class="text-right font-mono text-xs text-muted-foreground whitespace-nowrap">{eta_str}</DataTableCell> }
|
||||
}
|
||||
}).into_any()}
|
||||
|
||||
{move || visible_columns.get().contains("AddedDate").then({
|
||||
let date = t.added_date;
|
||||
move || {
|
||||
let date = torrent.get().map(|t| t.added_date).unwrap_or(0);
|
||||
let date_str = format_date(date);
|
||||
view! { <DataTableCell class="text-right font-mono text-xs text-muted-foreground whitespace-nowrap">{date_str}</DataTableCell> }
|
||||
}
|
||||
@@ -761,8 +764,8 @@ fn TorrentCard(
|
||||
<span class="font-bold text-primary">{format!("{:.1}%", t.percent_complete)}</span>
|
||||
</div>
|
||||
<Progress
|
||||
value=Signal::derive(move || t.percent_complete)
|
||||
class=if t.status == shared::TorrentStatus::Error { "bg-destructive/20 [&>div]:bg-destructive".to_string() } else { "".to_string() }
|
||||
value=Signal::derive(move || torrent.get().map(|t| t.percent_complete).unwrap_or(0.0))
|
||||
class=move || if torrent.get().map(|t| t.status == shared::TorrentStatus::Error).unwrap_or(false) { "bg-destructive/20 [&>div]:bg-destructive".to_string() } else { "".to_string() }
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -787,8 +790,8 @@ fn TorrentCard(
|
||||
</div>
|
||||
</div>
|
||||
</TorrentContextMenu>
|
||||
}
|
||||
}
|
||||
}.into_any()
|
||||
}.into_any()
|
||||
}
|
||||
</Show>
|
||||
}.into_any()
|
||||
|
||||
Reference in New Issue
Block a user