fix(ui): refactor FileContextMenu to auticlose and match homepage
All checks were successful
Build MIPS Binary / build (push) Successful in 1m59s

This commit is contained in:
spinline
2026-02-21 01:13:57 +03:00
parent 45271b5060
commit daa24dd7ec

View File

@@ -105,8 +105,12 @@ fn FileRow(file: TorrentFile, hash: String, refresh_action: Action<String, Vec<T
});
view! {
<ContextMenu>
<ContextMenuTrigger attr:id=context_id.clone()>
<FileContextMenu
torrent_hash=hash
file_index=f_idx
refresh_action=refresh_action
set_priority=set_priority
>
<TableRow class="hover:bg-muted/50 transition-colors group">
<TableCell class="text-center text-xs text-muted-foreground">{file.index}</TableCell>
<TableCell class="font-medium text-xs break-all max-w-[200px] md:max-w-md" attr:title=move || path_clone.clone()>
@@ -129,17 +133,39 @@ fn FileRow(file: TorrentFile, hash: String, refresh_action: Action<String, Vec<T
}
</TableCell>
</TableRow>
</FileContextMenu>
}
}
#[component]
fn FileContextMenu(
children: Children,
torrent_hash: String,
file_index: u32,
refresh_action: Action<String, Vec<TorrentFile>>,
set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>,
) -> impl IntoView {
let hash_c1 = torrent_hash.clone();
let hash_c2 = torrent_hash.clone();
let hash_c3 = torrent_hash.clone();
view! {
<ContextMenu>
<ContextMenuTrigger>
{children()}
</ContextMenuTrigger>
<ContextMenuContent class="w-48">
<ContextMenuLabel>"Dosya Önceliği"</ContextMenuLabel>
<ContextMenuGroup>
<ContextMenuItem on:click={
let h = hash.clone();
let h = hash_c1;
let ra = refresh_action.clone();
let sp = set_priority.clone();
move |_| {
set_priority.dispatch((h.clone(), f_idx, 2));
sp.dispatch((h.clone(), file_index, 2));
ra.dispatch(h.clone());
crate::components::ui::context_menu::close_context_menu();
}
}>
<icons::ChevronsUp class="text-green-500" />
@@ -147,11 +173,13 @@ fn FileRow(file: TorrentFile, hash: String, refresh_action: Action<String, Vec<T
</ContextMenuItem>
<ContextMenuItem on:click={
let h = hash.clone();
let h = hash_c2;
let ra = refresh_action.clone();
let sp = set_priority.clone();
move |_| {
set_priority.dispatch((h.clone(), f_idx, 1));
sp.dispatch((h.clone(), file_index, 1));
ra.dispatch(h.clone());
crate::components::ui::context_menu::close_context_menu();
}
}>
<icons::Minus class="text-blue-500" />
@@ -159,11 +187,13 @@ fn FileRow(file: TorrentFile, hash: String, refresh_action: Action<String, Vec<T
</ContextMenuItem>
<ContextMenuItem class="text-destructive focus:bg-destructive/10" on:click={
let h = hash.clone();
let h = hash_c3;
let ra = refresh_action.clone();
let sp = set_priority.clone();
move |_| {
set_priority.dispatch((h.clone(), f_idx, 0));
sp.dispatch((h.clone(), file_index, 0));
ra.dispatch(h.clone());
crate::components::ui::context_menu::close_context_menu();
}
}>
<icons::X />