diff --git a/Cargo.toml b/Cargo.toml index dcdbbffa..ec35710a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ keywords = ["solana", "crypto", "mining"] [features] default = [] +bundle = [] desktop = [ "async-tungstenite", "dioxus-desktop", diff --git a/src/components/miner_toolbar/miner_toolbar_active.rs b/src/components/miner_toolbar/miner_toolbar_active.rs index d1e17ac0..92764f86 100644 --- a/src/components/miner_toolbar/miner_toolbar_active.rs +++ b/src/components/miner_toolbar/miner_toolbar_active.rs @@ -2,10 +2,7 @@ use dioxus::prelude::*; use dioxus_router::prelude::Link; use crate::{ - components::{ - ActivityIndicator, IsToolbarOpen, MinerDisplayHash, OreIcon, Spinner, StopButton, Tooltip, - TooltipDirection, WarningIcon, - }, + components::{ActivityIndicator, IsToolbarOpen, MinerDisplayHash, Spinner, StopButton}, hooks::{use_power_level, use_priority_fee, PowerLevel, PriorityFee}, metrics::{track, AppEvent}, miner::Miner, @@ -224,43 +221,6 @@ pub fn PowerLevelConfig(cx: Scope) -> Element { } } -#[component] -pub fn MinerDataOre<'a>(cx: Scope, title: &'a str, tooltip: &'a str, amount: String) -> Element { - let container_class = "flex flex-col gap-0 shrink h-min"; - let header_container_class = "flex flex-row justify-start gap-1.5"; - let header_class = "font-medium text-xs z-0 text-nowrap opacity-80"; - let value_class = "font-medium text-white h-8"; - render! { - div { - class: "{container_class} w-full", - div { - class: "{header_container_class}", - p { - class: "{header_class}", - "{title}" - } - Tooltip { - text: "{tooltip}", - direction: TooltipDirection::Right - } - } - div { - class: "flex flex-row gap-8", - p { - class: "{value_class} flex flex-row flex-nowrap text-nowrap place-items-baseline", - OreIcon { - class: "w-4 h-4 my-auto", - } - span { - class: "ml-1.5 my-auto", - "{amount}" - } - } - } - } - } -} - #[component] fn DownloadLink(cx: Scope) -> Element { if cfg!(feature = "web") { diff --git a/src/components/mod.rs b/src/components/mod.rs index 74ccbe5c..ec1cd26e 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -18,12 +18,10 @@ mod miner_toolbar; mod navbar; mod ore_economics; mod page_not_found; -mod power_bar; mod send; mod settings; mod spinner; mod stop_button; -mod tooltip; mod tutorial; mod tx; mod user; @@ -50,12 +48,10 @@ pub use miner_toolbar::*; pub use navbar::*; pub use ore_economics::*; pub use page_not_found::*; -pub use power_bar::*; pub use send::*; pub use settings::*; pub use spinner::*; pub use stop_button::*; -pub use tooltip::*; pub use tutorial::*; pub use tx::*; pub use user::*; diff --git a/src/components/power_bar.rs b/src/components/power_bar.rs deleted file mode 100644 index afa0bd98..00000000 --- a/src/components/power_bar.rs +++ /dev/null @@ -1,137 +0,0 @@ -use dioxus::prelude::*; -use dioxus_router::prelude::Link; - -use crate::{ - components::WarningIcon, - hooks::{use_power_level, PowerLevel}, - route::Route, -}; - -#[component] -pub fn MinerPower(cx: Scope) -> Element { - render! { - div { - class: "flex flex-col gap-4 mt-auto", - div { - class: "flex flex-row justify-between", - - } - // PowerHeader {} - // div { - // class: "mt-1", - // PowerBar {} - // } - // div { - // class: "mt-2 sm:mt-4", - // DownloadLink {} - // } - } - } -} - -#[component] -fn PowerHeader(cx: Scope) -> Element { - render! { - div { - class: "flex flex-col gap-2", - h2 { - class: "text-xl text-white font-semibold", - "Power level" - } - p { - "Select how much power you would like to allocate to mining." - } - // p { - // class: "text-sm text-white opacity-80", - // "Higher power levels can earn more rewards but may impact your computer's battery life." - // } - } - } -} - -#[component] -fn PowerBar(cx: Scope) -> Element { - let power_level = use_power_level(cx); - let hover_level = use_state::>(cx, || None); - render! { - div { - class: "flex flex-row gap-1 w-full", - PowerBarLevel { id: 0, power_level: power_level, hover_level: hover_level } - PowerBarLevel { id: 1, power_level: power_level, hover_level: hover_level } - PowerBarLevel { id: 2, power_level: power_level, hover_level: hover_level } - PowerBarLevel { id: 3, power_level: power_level, hover_level: hover_level } - PowerBarLevel { id: 4, power_level: power_level, hover_level: hover_level } - PowerBarLevel { id: 5, power_level: power_level, hover_level: hover_level } - PowerBarLevel { id: 6, power_level: power_level, hover_level: hover_level } - PowerBarLevel { id: 7, power_level: power_level, hover_level: hover_level } - } - } -} - -#[component] -fn PowerBarLevel<'a>( - cx: Scope, - id: u8, - power_level: &'a UseSharedState, - hover_level: &'a UseState>, -) -> Element { - let rounded = if id.eq(&0) { - "rounded-l-full" - } else if id.eq(&7) { - "rounded-r-full" - } else { - "" - }; - let allowed = if cfg!(feature = "web") && id.gt(&0) { - "hover:cursor-not-allowed" - } else { - "" - }; - let opacity = if cfg!(feature = "web") { - if id.eq(&0) { - "" - } else { - "opacity-40" - } - } else if let Some(hover_level) = hover_level.get() { - if id.le(&power_level.read().0) { - if id.le(hover_level) { - "" - } else { - "opacity-40" - } - } else if id.le(hover_level) { - "opacity-50" - } else { - "opacity-40" - } - } else if id.le(&power_level.read().0) { - "" - } else { - "opacity-40" - }; - let title = if cfg!(feature = "web") { - if id.eq(&0) { - "" - } else { - "This power level is not suppported by your web browser." - } - } else { - "" - }; - render! { - button { - class: "w-full h-4 bg-white transition-opacity {rounded} {opacity} {allowed}", - title: "{title}", - onmouseover: move |_| { - hover_level.set(Some(*id)); - }, - onmouseout: move |_| { - hover_level.set(None); - }, - onclick: move |_| { - *power_level.write() = PowerLevel(*id); - } - } - } -} diff --git a/src/components/tooltip.rs b/src/components/tooltip.rs deleted file mode 100644 index 2d5e819c..00000000 --- a/src/components/tooltip.rs +++ /dev/null @@ -1,36 +0,0 @@ -use dioxus::prelude::*; - -use crate::components::InfoIcon; - -pub enum TooltipDirection { - Right, - // Left, - // Center, -} - -#[derive(Props)] -pub struct TooltipProps<'a> { - text: &'a str, - direction: TooltipDirection, -} - -pub fn Tooltip<'a>(cx: Scope<'a, TooltipProps<'a>>) -> Element<'a> { - let info_icon_class = "w-3 h-3 my-auto opacity-80"; - let direction_class = match cx.props.direction { - TooltipDirection::Right => "left-[50%]", - // TooltipDirection::Left => "right-[50%]", - // TooltipDirection::Center => "left-[50%] -translate-x-1/2", - }; - render! { - div { - class: "relative flex group overflow-visible", - InfoIcon { - class: "{info_icon_class}" - } - span { - class: "bottom-[100%] z-[100] absolute hidden group-hover:block w-max max-w-44 bg-black drop-shadow rounded-sm py-1.5 px-2.5 text-xs text-white {direction_class}", - "{cx.props.text}" - } - } - } -} diff --git a/src/hooks/use_account.rs b/src/hooks/use_account.rs index a39ba117..30adeac1 100644 --- a/src/hooks/use_account.rs +++ b/src/hooks/use_account.rs @@ -4,10 +4,6 @@ use std::time::Duration; use dioxus::prelude::*; use dioxus_std::utils::rw::{use_rw, UseRw}; use ore::utils::AccountDeserialize; -#[cfg(feature = "desktop")] -use solana_account_decoder::UiAccountData; -#[cfg(feature = "desktop")] -use solana_client::pubsub_client::PubsubClient; #[cfg(feature = "web")] use solana_client_wasm::solana_sdk::pubkey::Pubkey; #[cfg(feature = "desktop")] diff --git a/src/hooks/use_sol_balance.rs b/src/hooks/use_sol_balance.rs index 993d39bc..e224a750 100644 --- a/src/hooks/use_sol_balance.rs +++ b/src/hooks/use_sol_balance.rs @@ -3,9 +3,9 @@ use dioxus_std::utils::rw::use_rw; #[cfg(feature = "desktop")] use solana_client::pubsub_client::PubsubClient; +use crate::gateway::AsyncResult; #[cfg(feature = "desktop")] use crate::gateway::RPC_WSS_URL; -use crate::{gateway::AsyncResult, metrics::track}; use super::{use_gateway, use_pubkey}; diff --git a/src/hooks/use_transfers_websocket.rs b/src/hooks/use_transfers_websocket.rs index 0128f786..641cd7a6 100644 --- a/src/hooks/use_transfers_websocket.rs +++ b/src/hooks/use_transfers_websocket.rs @@ -7,8 +7,6 @@ use futures::StreamExt; use gloo::net::websocket::{futures::WebSocket, Message, WebSocketError}; use ore_types::Transfer; #[cfg(feature = "desktop")] -use solana_sdk::pubkey::Pubkey; -#[cfg(feature = "desktop")] use url::Url; #[cfg(feature = "web")] diff --git a/src/main.rs b/src/main.rs index b52d8110..9c3d6a17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#![cfg_attr(feature = "bundle", windows_subsystem = "windows")] #![allow(non_snake_case)] use std::rc::Rc; @@ -38,10 +39,8 @@ fn main() { #[cfg(feature = "desktop")] fn main() { env_logger::init(); - // dioxus_desktop::launch_cfg( - dioxus_desktop::launch::launch( + dioxus_desktop::launch_cfg( App, - vec![], dioxus_desktop::Config::new() .with_custom_head(r#""#.to_string()), ); diff --git a/src/metrics.rs b/src/metrics.rs index 325d237e..026b249c 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -44,7 +44,12 @@ extern "C" { fn trackEvent(name: &str, value: Option) -> Result<(), JsValue>; } +#[cfg(feature = "web")] pub fn track(event: AppEvent, value: Option) { - #[cfg(feature = "web")] trackEvent(event.to_string().as_str(), value).ok(); } + +#[cfg(feature = "desktop")] +pub fn track(_event: AppEvent, _value: Option) { + // Noop +}