fix(frontend): leptos 0.8 migration fixes - Callback::run, StoredValue::new_local, traits
Some checks failed
Build MIPS Binary / build (push) Failing after 1m22s
Some checks failed
Build MIPS Binary / build (push) Failing after 1m22s
This commit is contained in:
@@ -9,6 +9,7 @@ use leptos::logging;
|
|||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
use leptos_router::components::{Router, Routes, Route};
|
use leptos_router::components::{Router, Routes, Route};
|
||||||
use leptos_router::hooks::use_navigate;
|
use leptos_router::hooks::use_navigate;
|
||||||
|
// use leptos_router::PossibleRouteMatch; // Bu trait prelude ile gelmeli veya public olmayabilir.
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn App() -> impl IntoView {
|
pub fn App() -> impl IntoView {
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ pub fn ContextMenu(
|
|||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let container_ref = create_node_ref::<html::Div>();
|
let container_ref = create_node_ref::<html::Div>();
|
||||||
|
|
||||||
let _ = on_click_outside(container_ref, move |_| on_close.call(()));
|
let _ = on_click_outside(container_ref, move |_| on_close.run(()));
|
||||||
|
|
||||||
let handle_action = move |action: &str| {
|
let handle_action = move |action: &str| {
|
||||||
let hash = torrent_hash.clone();
|
let hash = torrent_hash.clone();
|
||||||
let action_str = action.to_string();
|
let action_str = action.to_string();
|
||||||
|
|
||||||
logging::log!("ContextMenu: Action '{}' for hash '{}'", action_str, hash);
|
logging::log!("ContextMenu: Action '{}' for hash '{}'", action_str, hash);
|
||||||
on_action.call((action_str, hash)); // Delegate FIRST
|
on_action.run((action_str, hash)); // Delegate FIRST
|
||||||
on_close.call(()); // Close menu AFTER
|
on_close.run(()); // Close menu AFTER
|
||||||
};
|
};
|
||||||
|
|
||||||
if !visible {
|
if !visible {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use leptos::task::spawn_local;
|
|||||||
use leptos_use::storage::use_local_storage;
|
use leptos_use::storage::use_local_storage;
|
||||||
use ::codee::string::FromToStringCodec;
|
use ::codee::string::FromToStringCodec;
|
||||||
use shared::GlobalLimitRequest;
|
use shared::GlobalLimitRequest;
|
||||||
|
use reactive_graph::traits::{Get, Set, GetUntracked};
|
||||||
use crate::api;
|
use crate::api;
|
||||||
|
|
||||||
fn format_bytes(bytes: i64) -> String {
|
fn format_bytes(bytes: i64) -> String {
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ pub fn Modal(
|
|||||||
#[prop(into, default = "Cancel".to_string())] cancel_text: String,
|
#[prop(into, default = "Cancel".to_string())] cancel_text: String,
|
||||||
#[prop(into, default = false)] is_danger: bool,
|
#[prop(into, default = false)] is_danger: bool,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let title = store_value(title);
|
let title = StoredValue::new_local(title);
|
||||||
// Eagerly render children to a Fragment, which is Clone
|
// Eagerly render children to a Fragment, which is Clone
|
||||||
let child_view = store_value(children());
|
let child_view = StoredValue::new_local(children());
|
||||||
let on_confirm = store_value(on_confirm);
|
let on_confirm = StoredValue::new_local(on_confirm);
|
||||||
let on_cancel = store_value(on_cancel);
|
let on_cancel = StoredValue::new_local(on_cancel);
|
||||||
let confirm_text = store_value(confirm_text);
|
let confirm_text = StoredValue::new_local(confirm_text);
|
||||||
let cancel_text = store_value(cancel_text);
|
let cancel_text = StoredValue::new_local(cancel_text);
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<Show when=move || visible.get() fallback=|| ()>
|
<Show when=move || visible.get() fallback=|| ()>
|
||||||
@@ -35,7 +35,7 @@ pub fn Modal(
|
|||||||
<div class="flex justify-end gap-3">
|
<div class="flex justify-end gap-3">
|
||||||
<button
|
<button
|
||||||
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2"
|
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2"
|
||||||
on:click=move |_| on_cancel.with_value(|cb| cb.call(()))
|
on:click=move |_| on_cancel.with_value(|cb| cb.run(()))
|
||||||
>
|
>
|
||||||
{cancel_text.get_value()}
|
{cancel_text.get_value()}
|
||||||
</button>
|
</button>
|
||||||
@@ -46,7 +46,7 @@ pub fn Modal(
|
|||||||
))
|
))
|
||||||
on:click=move |_| {
|
on:click=move |_| {
|
||||||
logging::log!("Modal: Confirm clicked");
|
logging::log!("Modal: Confirm clicked");
|
||||||
on_confirm.with_value(|cb| cb.call(()))
|
on_confirm.with_value(|cb| cb.run(()))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{confirm_text.get_value()}
|
{confirm_text.get_value()}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ pub fn AddTorrentModal(
|
|||||||
if let Some(dialog) = dialog_ref.get() {
|
if let Some(dialog) = dialog_ref.get() {
|
||||||
dialog.close();
|
dialog.close();
|
||||||
}
|
}
|
||||||
on_close.call(());
|
on_close.run(());
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
logging::error!("Failed to add torrent: {:?}", e);
|
logging::error!("Failed to add torrent: {:?}", e);
|
||||||
@@ -64,7 +64,7 @@ pub fn AddTorrentModal(
|
|||||||
if let Some(dialog) = dialog_ref.get() {
|
if let Some(dialog) = dialog_ref.get() {
|
||||||
dialog.close();
|
dialog.close();
|
||||||
}
|
}
|
||||||
on_close.call(());
|
on_close.run(());
|
||||||
};
|
};
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
|
|||||||
Reference in New Issue
Block a user