Skip to content

Commit

Permalink
remove unused imports and unnecessary parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
cookspam committed Aug 16, 2024
1 parent 55ad1a6 commit d8338be
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 261 deletions.
9 changes: 4 additions & 5 deletions src/components/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ use ore_types::{Transfer, TransferType};

use crate::{
components::{GlobeIcon, SpamIcon, UserBubble, UserIcon},
gateway::AsyncResult,
hooks::{use_pubkey, use_transfers, ACTIVITY_TABLE_PAGE_LIMIT},
hooks::{use_pubkey, ACTIVITY_TABLE_PAGE_LIMIT},
route::Route,
utils::asset_path,
};

#[derive(Debug)]
pub enum ActivityFilter {
Global,
Personal,
Personal
}

#[component]
pub fn Activity(cx: Scope) -> Element {
let filter = use_state(cx, || ActivityFilter::Global);
let offset = use_state(cx, || 0u64);
// let filter = use_state(cx, || ActivityFilter::Global);
// let offset = use_state(cx, || 0u64);
// let (transfers, has_more) = use_transfers(cx, filter, offset);
let spam_gang = asset_path("mining_gang_resized.png");
let go = asset_path("letsgo.png");
Expand Down
68 changes: 0 additions & 68 deletions src/components/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,53 +471,6 @@ pub fn XIcon<'a>(cx: Scope<'a, IconProps<'a>>) -> Element {
}
}

pub fn OreLogoIcon<'a>(cx: Scope<'a, IconProps<'a>>) -> Element {
let class = cx.props.class.unwrap_or("");
render! {
svg {
view_box: "0 0 416 142",
fill: "currentColor",
class: "{class}",
path {
fill_rule: "evenodd",
clip_rule: "evenodd",
d: "M0.183896 126.277C-0.0612986 126.031 -0.0612986 125.634 0.183896 125.389L18.5017 107.071C18.8439 106.728 18.8913 106.191 18.6205 105.79C11.8537 95.7702 7.90257 83.6927 7.90257 70.692C7.90257 36.0144 36.0143 7.90263 70.692 7.90263C83.6925 7.90263 95.7702 11.8536 105.79 18.6206C106.191 18.8915 106.729 18.8441 107.071 18.5019L125.389 0.183953C125.634 -0.0613178 126.031 -0.0613178 126.276 0.183953L141.816 15.7237C142.061 15.969 142.061 16.3663 141.816 16.6116L123.374 35.0533C123.036 35.3917 122.986 35.922 123.248 36.3223C129.718 46.1966 133.481 58.0051 133.481 70.692C133.481 105.37 105.37 133.481 70.692 133.481C58.0048 133.481 46.1965 129.718 36.3223 123.248C35.9219 122.986 35.3917 123.036 35.0532 123.375L16.6115 141.816C16.3663 142.062 15.9687 142.062 15.7235 141.816L0.183896 126.277ZM70.692 110.249C64.1592 110.249 57.9963 108.665 52.5663 105.861C45.5372 102.231 39.736 96.5565 35.9499 89.6226C32.8797 83.9998 31.1346 77.5498 31.1346 70.692C31.1346 48.8451 48.8451 31.1347 70.692 31.1347C77.5497 31.1347 83.9997 32.8798 89.6225 35.95C96.5561 39.7357 102.231 45.5376 105.861 52.5665C108.666 57.9968 110.249 64.1592 110.249 70.692C110.249 92.5389 92.5389 110.249 70.692 110.249Z"
}
path {
d: "M358.969 111.552V30.4483H415.668V48.0593H380.867V61.6538H414.042V79.149H380.867V93.9407H415.664V111.552H358.969Z"
}
path {
d: "M282.189 111.552V30.4483H319.034C334.675 30.4483 347.767 41.8028 347.767 58.8345C347.767 70.5945 341.685 79.6897 332.589 84.2662L350.78 111.552H325.985L312.429 89.3062H304.087V111.552H282.189ZM314.863 50.4924H304.087V69.4938H314.863C322.394 69.4938 326.217 65.5545 326.217 59.8772C326.217 54.2 322.394 50.4924 314.863 50.4924Z"
}
path {
d: "M232 113C206.083 113 190 92.7479 190 71C190 49.2521 206.083 29 232 29C257.917 29 274 49.2521 274 71C274 92.7479 257.917 113 232 113ZM232 91.8274C244.38 91.8274 252.017 81.9315 252.017 71C252.017 60.0685 244.38 50.1726 232 50.1726C219.62 50.1726 211.983 60.0685 211.983 71C211.983 81.9315 219.62 91.8274 232 91.8274Z"
}
}
}
}

pub fn OreWordmarkIcon<'a>(cx: Scope<'a, IconProps<'a>>) -> Element {
let class = cx.props.class.unwrap_or("");
render! {
svg {
view_box: "0 0 234 88",
fill: "currentColor",
class: "{class}",
path {
fill_rule: "evenodd",
clip_rule: "evenodd",
d: "M175.14 86V2H233.864V20.24H197.82V34.32H232.18V52.44H197.82V67.76H233.86V86H175.14Z"
}
path {
d: "M95.618 86V2H133.778C149.978 2 163.538 13.76 163.538 31.4C163.538 43.58 157.238 53 147.818 57.74L166.658 86H140.978L126.938 62.96H118.298V86H95.618ZM129.458 22.76H118.298V42.44H129.458C137.258 42.44 141.218 38.36 141.218 32.48C141.218 26.6 137.258 22.76 129.458 22.76Z"
}
path {
d: "M43.6361 87.5C16.7931 87.5 0.136078 66.5247 0.136078 44C0.136078 21.4753 16.7931 0.5 43.6361 0.5C70.4791 0.5 87.1361 21.4753 87.1361 44C87.1361 66.5247 70.4791 87.5 43.6361 87.5ZM43.6361 65.5712C56.4584 65.5712 64.3675 55.3219 64.3675 44C64.3675 32.6781 56.4584 22.4288 43.6361 22.4288C30.8138 22.4288 22.9047 32.6781 22.9047 44C22.9047 55.3219 30.8138 65.5712 43.6361 65.5712Z"
}
}
}
}

pub fn TreasuryIcon<'a>(cx: Scope<'a, IconProps<'a>>) -> Element {
let class = cx.props.class.unwrap_or("");
render! {
Expand Down Expand Up @@ -560,27 +513,6 @@ pub fn BusIcon<'a>(cx: Scope<'a, IconProps<'a>>) -> Element {
}
}

pub fn PieIcon<'a>(cx: Scope<'a, IconProps<'a>>) -> Element {
let class = cx.props.class.unwrap_or("");
render! {
svg {
view_box: "0 0 24 24",
fill: "currentColor",
class: "{class}",
path {
fill_rule: "evenodd",
clip_rule: "evenodd",
d: "M2.25 13.5a8.25 8.25 0 0 1 8.25-8.25.75.75 0 0 1 .75.75v6.75H18a.75.75 0 0 1 .75.75 8.25 8.25 0 0 1-16.5 0Z"
}
path {
fill_rule: "evenodd",
clip_rule: "evenodd",
d: "M12.75 3a.75.75 0 0 1 .75-.75 8.25 8.25 0 0 1 8.25 8.25.75.75 0 0 1-.75.75h-7.5a.75.75 0 0 1-.75-.75V3Z"
}
}
}
}

#[component]
pub fn LockOpenIcon<'a>(cx: Scope<'a, IconProps<'a>>) -> Element {
let class = cx.props.class.unwrap_or("");
Expand Down
11 changes: 4 additions & 7 deletions src/components/landing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};

use dioxus::prelude::*;
use dioxus_router::prelude::*;
use ore_types::Transfer;
#[cfg(feature = "web")]
use web_time::{Duration, SystemTime, UNIX_EPOCH};

use crate::{
components::{ActivityFilter, ActivityIndicator, Footer, SpamIcon},
components::{Footer, SpamIcon},
gateway::AsyncResult,
hooks::{use_is_onboarded, use_ore_supply, use_transfers, use_treasury},
hooks::{use_is_onboarded, use_ore_supply, use_treasury},
utils::asset_path,
Route,
};


#[component]
pub fn Landing(cx: Scope) -> Element {
let is_onboarded = use_is_onboarded(cx);
let nav = use_navigator(cx);
// let is_onboarded = use_is_onboarded(cx);
// let nav = use_navigator(cx);


// If the user is already onboarded, redirect to home.
Expand Down
18 changes: 5 additions & 13 deletions src/components/leaderboard.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
use std::{rc::Rc, str::FromStr,};
use std::borrow::Cow;
use std::string::String;
//use plotters::prelude::*;
use std::error::Error;
use plotters_svg::SVGBackend;
use wasm_bindgen::prelude::*;
use web_sys::console;
use chrono::{NaiveDateTime, Datelike, Timelike, Utc, DateTime};
use chrono::{NaiveDateTime, Datelike, Timelike};
use web_time::{SystemTime, Duration, UNIX_EPOCH};

use reqwest::Client;
use serde::Deserialize;
use wasm_bindgen::prelude::*;

use dioxus::prelude::*;
use dioxus_router::prelude::*;

#[cfg(feature = "desktop")]
use solana_account_decoder::parse_token::UiTokenAccount;
#[cfg(feature = "desktop")]
use solana_account_decoder::parse_token::UiTokenAmount;
#[cfg(feature = "web")]
use solana_client_wasm::solana_sdk::pubkey::Pubkey;
#[cfg(feature = "web")]
use solana_extra_wasm::account_decoder::parse_token::UiTokenAccount;
#[cfg(feature = "web")]
use solana_extra_wasm::account_decoder::parse_token::UiTokenAmount;
#[cfg(feature = "desktop")]
use solana_sdk::pubkey::Pubkey;

use crate::{
components::{SpamIcon, Footer},
components::{SpamIcon},
gateway::{ore_token_account_address, AsyncResult, Gateway, GatewayError, proof_pubkey},
hooks::{use_gateway, use_ore_supply, use_treasury, use_ore_balance_user, use_user_proof},
hooks::{use_gateway, use_ore_supply, use_treasury},
route::Route,
utils::asset_path, // Add this line to use asset_path function
};
Expand Down Expand Up @@ -144,7 +136,7 @@ pub fn SupplyStats(cx: Scope) -> Element {
"monthly" => format!("{}", date_time.format("%B")), // Full month name
_ => {
let mut hourly_hour = date_time.hour();
if (date_time.minute() != 0) {
if date_time.minute() != 0 {
hourly_hour += 1;
if hourly_hour >= 24 {
hourly_hour -= 24;
Expand Down Expand Up @@ -424,7 +416,7 @@ pub fn QuerySpamBalance(cx: Scope) -> Element {
let pubkey = use_state(cx, || "".to_string());
let gateway = use_gateway(cx);

use_future(cx, (pubkey), |pubkey| {
use_future(cx, pubkey, |pubkey| {
let gateway = gateway.clone();
let claimable_spam_balance = claimable_spam_balance.clone();
let spam_balance = spam_balance.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use solana_client_wasm::solana_sdk::native_token::LAMPORTS_PER_SOL;
use solana_sdk::native_token::LAMPORTS_PER_SOL;

use crate::{
components::{BackupKeypairWarning, Copyable, Footer},
components::{BackupKeypairWarning, Copyable},
gateway::{AsyncResult, RPC_URL},
hooks::{
use_appearance, use_explorer, use_pubkey, use_rpc_url, use_show_backup_warning,
Expand Down
76 changes: 38 additions & 38 deletions src/hooks/use_transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,44 @@ pub fn use_user_transfers(
(transfers.read().unwrap().clone(), *has_more.get())
}

pub fn use_transfers(
cx: &ScopeState,
filter: &UseState<ActivityFilter>,
offset: &UseState<u64>,
) -> (AsyncResult<Vec<Transfer>>, bool) {
let gateway = use_gateway(cx);
let pubkey = use_pubkey(cx);
let transfers = use_rw::<AsyncResult<Vec<Transfer>>>(cx, || AsyncResult::Loading);
let has_more = use_state(cx, || false);
// pub fn use_transfers(
// cx: &ScopeState,
// filter: &UseState<ActivityFilter>,
// offset: &UseState<u64>,
// ) -> (AsyncResult<Vec<Transfer>>, bool) {
// let gateway = use_gateway(cx);
// let pubkey = use_pubkey(cx);
// let transfers = use_rw::<AsyncResult<Vec<Transfer>>>(cx, || AsyncResult::Loading);
// let has_more = use_state(cx, || false);

use_transfers_websocket(
cx,
filter,
transfers,
offset,
has_more,
ACTIVITY_TABLE_PAGE_LIMIT,
);
// use_transfers_websocket(
// cx,
// filter,
// transfers,
// offset,
// has_more,
// ACTIVITY_TABLE_PAGE_LIMIT,
// );

let _ = use_future(cx, (&filter.clone(), &offset.clone()), |_| {
let gateway = gateway.clone();
let transfers = transfers.clone();
let has_more = has_more.clone();
let offset = *offset.current();
let user = match filter.get() {
ActivityFilter::Global => None,
ActivityFilter::Personal => Some(pubkey),
};
async move {
if let Some(res) = gateway
.list_transfers(user, offset, ACTIVITY_TABLE_PAGE_LIMIT)
.await
{
transfers.write(AsyncResult::Ok(res.data)).unwrap();
has_more.set(res.has_more);
};
}
});
// let _ = use_future(cx, (&filter.clone(), &offset.clone()), |_| {
// let gateway = gateway.clone();
// let transfers = transfers.clone();
// let has_more = has_more.clone();
// let offset = *offset.current();
// let user = match filter.get() {
// ActivityFilter::Global => None,
// ActivityFilter::Personal => Some(pubkey),
// };
// async move {
// if let Some(res) = gateway
// .list_transfers(user, offset, ACTIVITY_TABLE_PAGE_LIMIT)
// .await
// {
// transfers.write(AsyncResult::Ok(res.data)).unwrap();
// has_more.set(res.has_more);
// };
// }
// });

(transfers.read().unwrap().clone(), *has_more.get())
}
// (transfers.read().unwrap().clone(), *has_more.get())
// }
Loading

0 comments on commit d8338be

Please sign in to comment.