Skip to content

Commit b99aad3

Browse files
committed
remove all websockets and poll
1 parent 667014f commit b99aad3

File tree

6 files changed

+49
-57
lines changed

6 files changed

+49
-57
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ readme = "./README.md"
1111
keywords = ["solana", "crypto", "mining"]
1212

1313
[features]
14-
default = []
14+
default = ["web"]
1515
bundle = []
1616
desktop = [
1717
"async-tungstenite",

public/tailwind.css

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,11 @@ h2:where(.dark, .dark *) {
840840
height: 2rem;
841841
}
842842

843+
.h-fit {
844+
height: -moz-fit-content;
845+
height: fit-content;
846+
}
847+
843848
.h-full {
844849
height: 100%;
845850
}
@@ -954,10 +959,22 @@ h2:where(.dark, .dark *) {
954959
max-width: 100%;
955960
}
956961

962+
.flex-auto {
963+
flex: 1 1 auto;
964+
}
965+
966+
.flex-none {
967+
flex: none;
968+
}
969+
957970
.flex-shrink {
958971
flex-shrink: 1;
959972
}
960973

974+
.flex-shrink-0 {
975+
flex-shrink: 0;
976+
}
977+
961978
.shrink {
962979
flex-shrink: 1;
963980
}
@@ -1200,6 +1217,11 @@ h2:where(.dark, .dark *) {
12001217
background-position: center;
12011218
}
12021219

1220+
.object-contain {
1221+
-o-object-fit: contain;
1222+
object-fit: contain;
1223+
}
1224+
12031225
.p-2 {
12041226
padding: 0.5rem;
12051227
}
@@ -1733,11 +1755,6 @@ h2:where(.dark, .dark *) {
17331755
background-color: rgb(49 49 51 / var(--tw-bg-opacity));
17341756
}
17351757

1736-
.hover\:bg-green-500:hover {
1737-
--tw-bg-opacity: 1;
1738-
background-color: rgb(10 207 134 / var(--tw-bg-opacity));
1739-
}
1740-
17411758
.hover\:bg-green-600:hover {
17421759
--tw-bg-opacity: 1;
17431760
background-color: rgb(0 184 124 / var(--tw-bg-opacity));
@@ -1849,10 +1866,6 @@ h2:where(.dark, .dark *) {
18491866
gap: 4rem;
18501867
}
18511868

1852-
.sm\:gap-3 {
1853-
gap: 0.75rem;
1854-
}
1855-
18561869
.sm\:gap-4 {
18571870
gap: 1rem;
18581871
}
@@ -2065,7 +2078,7 @@ h2:where(.dark, .dark *) {
20652078

20662079
.dark\:bg-gray-700:where(.dark, .dark *) {
20672080
--tw-bg-opacity: 1;
2068-
background-color: rgb(90 90 92 / var(--tw-bg-opacity));
2081+
background-color: rgb(112 112 113 / var(--tw-bg-opacity));
20692082
}
20702083

20712084
.dark\:bg-gray-900:where(.dark, .dark *) {
@@ -2085,7 +2098,7 @@ h2:where(.dark, .dark *) {
20852098

20862099
.dark\:text-gray-700:where(.dark, .dark *) {
20872100
--tw-text-opacity: 1;
2088-
color: rgb(90 90 92 / var(--tw-text-opacity));
2101+
color: rgb(112 112 113 / var(--tw-text-opacity));
20892102
}
20902103

20912104
.dark\:text-gray-900:where(.dark, .dark *) {
@@ -2100,12 +2113,12 @@ h2:where(.dark, .dark *) {
21002113

21012114
.dark\:placeholder-gray-700:where(.dark, .dark *)::-moz-placeholder {
21022115
--tw-placeholder-opacity: 1;
2103-
color: rgb(90 90 92 / var(--tw-placeholder-opacity));
2116+
color: rgb(112 112 113 / var(--tw-placeholder-opacity));
21042117
}
21052118

21062119
.dark\:placeholder-gray-700:where(.dark, .dark *)::placeholder {
21072120
--tw-placeholder-opacity: 1;
2108-
color: rgb(90 90 92 / var(--tw-placeholder-opacity));
2121+
color: rgb(112 112 113 / var(--tw-placeholder-opacity));
21092122
}
21102123

21112124
.dark\:placeholder-gray-800:where(.dark, .dark *)::-moz-placeholder {
@@ -2130,6 +2143,6 @@ h2:where(.dark, .dark *) {
21302143

21312144
.dark\:active\:bg-gray-700:active:where(.dark, .dark *) {
21322145
--tw-bg-opacity: 1;
2133-
background-color: rgb(90 90 92 / var(--tw-bg-opacity));
2146+
background-color: rgb(112 112 113 / var(--tw-bg-opacity));
21342147
}
21352148

src/components/miner_toolbar/miner_toolbar_insufficient_sol.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ pub fn MinerToolbarInsufficientBalanceOpen(cx: Scope) -> Element {
8585
}
8686
p {
8787
class: "text-lg",
88-
"Scan the QR code from your Solana wallet to fund your miner."
88+
"Scan the QR code from your Solana wallet to top up your miner."
8989
}
9090
p {
91-
class: "text-sm text-gray-300 dark:text-gray-700",
92-
"Top up with 0.1 SOL to begin mining."
91+
class: "text-sm text-gray-300",
92+
"Your miner keypair is stored on your local device and can be exported at anytime from settings."
9393
}
9494
}
9595
div {
@@ -111,7 +111,7 @@ pub fn MinerToolbarInsufficientBalanceOpen(cx: Scope) -> Element {
111111
// TODO Get referal code
112112
href: "https://www.coinbase.com/price/solana",
113113
target: "_blank",
114-
class: "font-medium text-center text-sm text-gray-300 dark:text-gray-700 hover:underline",
114+
class: "font-medium text-center text-sm text-gray-300 hover:underline",
115115
"Help! I don't have any SOL."
116116
}
117117
}

src/hooks/use_account.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub fn use_account<
2626
let gateway = use_gateway(cx);
2727

2828
let f = use_future(cx, (), |_| {
29-
log::info!("Refetching account: {:?}", address);
3029
let acc = acc.clone();
3130
let gateway = gateway.clone();
3231
async move {
@@ -42,8 +41,10 @@ pub fn use_account<
4241
let f = f.clone();
4342
async move {
4443
if let Some(d) = poll {
45-
async_std::task::sleep(Duration::from_secs(d)).await;
46-
f.restart();
44+
loop {
45+
async_std::task::sleep(Duration::from_secs(d)).await;
46+
f.restart();
47+
}
4748
}
4849
}
4950
});

src/hooks/use_sol_balance.rs

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
use dioxus::prelude::*;
22
use dioxus_std::utils::rw::use_rw;
3+
#[cfg(feature = "deskstop")]
4+
use std::time::Duration;
5+
#[cfg(feature = "web")]
6+
use web_time::Duration;
37

48
use crate::gateway::AsyncResult;
59

@@ -22,7 +26,7 @@ pub fn use_sol_balance_provider(cx: &ScopeState) {
2226
let gateway = use_gateway(cx);
2327

2428
// Fetch initial balance.
25-
use_future(cx, (), |_| {
29+
let f = use_future(cx, (), |_| {
2630
let balance = balance.clone();
2731
let gateway = gateway.clone();
2832
async move {
@@ -32,41 +36,15 @@ pub fn use_sol_balance_provider(cx: &ScopeState) {
3236
}
3337
});
3438

35-
// Subscribe to balance changes
39+
// Poll for future balance changes
3640
use_future(cx, (), |_| {
37-
#[cfg(feature = "web")]
38-
let gateway = gateway.clone();
39-
let balance_ = balance_.clone();
41+
let f = f.clone();
42+
let poll = 3;
4043
async move {
41-
#[cfg(feature = "web")]
42-
let _ = gateway
43-
.rpc
44-
.account_subscribe(address, move |account| {
45-
let lamports = account.value.unwrap().lamports;
46-
balance_.write(AsyncResult::Ok(SolBalance(lamports))).ok();
47-
})
48-
.await;
49-
50-
#[cfg(feature = "desktop")]
51-
std::thread::spawn(move || {
52-
match PubsubClient::account_subscribe(
53-
RPC_WSS_URL,
54-
&address,
55-
Some(solana_client::rpc_config::RpcAccountInfoConfig::default()),
56-
) {
57-
Ok((mut _sub, rx)) => {
58-
while let Ok(ui_account) = rx.recv() {
59-
let lamports = ui_account.value.lamports;
60-
balance_
61-
.write(AsyncResult::Ok(SolBalance(lamports)))
62-
.unwrap();
63-
}
64-
}
65-
Err(err) => {
66-
log::error!("Failed to subscribe to account: {:?}", err)
67-
}
68-
};
69-
});
44+
loop {
45+
async_std::task::sleep(Duration::from_secs(poll)).await;
46+
f.restart();
47+
}
7048
}
7149
});
7250

tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
100: '#e8e8ea',
2727
200: '#d6d6d8',
2828
300: '#b0b0b2',
29-
700: '#5a5a5c',
29+
700: '#707071',
3030
800: '#464648',
3131
900: '#313133',
3232
},

0 commit comments

Comments
 (0)