Skip to content

Commit

Permalink
[ABW-3911] Discover Radix dApps home card (#257)
Browse files Browse the repository at this point in the history
* wip

* bump to 1.1.48

* derive Ord and PartialOrd

* bump to 1.1.49
  • Loading branch information
danvleju-rdx authored Nov 11, 2024
1 parent 456272e commit 4a5a557
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/sargon-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon-uniffi"
# Don't forget to update version in crates/sargon/Cargo.toml
version = "1.1.48"
version = "1.1.49"
edition = "2021"
build = "build.rs"

Expand Down
4 changes: 4 additions & 0 deletions crates/sargon-uniffi/src/home_cards/home_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ pub enum HomeCard {
/// Content: "To use Radix Wallet with desktop browsers, finish setup by visiting wallet.radixdlt.com"
/// Action: None
Connector,

/// Content: "Start digging into Web3 dApps on the Radix Ecosystem directory."
/// Action: Redirect user to Radix Ecosystem.
DiscoverRadixDapps,
}
2 changes: 1 addition & 1 deletion crates/sargon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon"
# Don't forget to update version in crates/sargon-uniffi/Cargo.toml
version = "1.1.48"
version = "1.1.49"
edition = "2021"
build = "build.rs"

Expand Down
29 changes: 6 additions & 23 deletions crates/sargon/src/home_cards/home_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use std::cmp::Ordering;
PartialEq,
Eq,
Hash,
Ord,
PartialOrd,
derive_more::Display,
)]

Expand All @@ -32,6 +34,10 @@ pub enum HomeCard {
/// Content: "To use Radix Wallet with desktop browsers, finish setup by visiting wallet.radixdlt.com"
/// Action: None
Connector,

/// Content: "Start digging into Web3 dApps on the Radix Ecosystem directory."
/// Action: Redirect user to Radix Ecosystem.
DiscoverRadixDapps,
}

impl Identifiable for HomeCard {
Expand All @@ -52,29 +58,6 @@ impl HasSampleValues for HomeCard {
}
}

impl Ord for HomeCard {
fn cmp(&self, other: &Self) -> Ordering {
fn order_value(card: &HomeCard) -> usize {
use HomeCard::*;

match card {
StartRadQuest => 0,
ContinueRadQuest => 1,
Dapp { .. } => 2,
Connector => 3,
}
}

order_value(self).cmp(&order_value(other))
}
}

impl PartialOrd for HomeCard {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

#[cfg(test)]
mod tests {
use crate::prelude::*;
Expand Down
5 changes: 5 additions & 0 deletions crates/sargon/src/home_cards/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl HomeCardsManager {
let default_cards = HomeCards::from_iter([
HomeCard::Connector,
HomeCard::StartRadQuest,
HomeCard::DiscoverRadixDapps,
]);
let updated_cards = self
.update_cards(|write_guard| {
Expand Down Expand Up @@ -333,6 +334,7 @@ mod tests {
let expected_cards = HomeCards::from_iter(vec![
HomeCard::StartRadQuest,
HomeCard::Connector,
HomeCard::DiscoverRadixDapps,
]);

manager.wallet_created().await.unwrap();
Expand Down Expand Up @@ -363,6 +365,7 @@ mod tests {
let expected_cards = HomeCards::from_iter(vec![
HomeCard::StartRadQuest,
HomeCard::Connector,
HomeCard::DiscoverRadixDapps,
]);
let observer = Arc::new(MockHomeCardsObserver::new());
let manager = SUT::new(
Expand Down Expand Up @@ -404,6 +407,7 @@ mod tests {
HomeCard::Dapp { icon_url: None },
HomeCard::ContinueRadQuest,
HomeCard::Connector,
HomeCard::DiscoverRadixDapps,
]);
let handled_cards = observer.handled_cards.lock().unwrap().clone();
pretty_assertions::assert_eq!(handled_cards, Some(expected_cards));
Expand Down Expand Up @@ -442,6 +446,7 @@ mod tests {
HomeCard::ContinueRadQuest,
HomeCard::Dapp { icon_url: None },
HomeCard::Connector,
HomeCard::DiscoverRadixDapps,
]);
let handled_cards = observer.handled_cards.lock().unwrap().clone();
pretty_assertions::assert_eq!(handled_cards, Some(expected_cards));
Expand Down

0 comments on commit 4a5a557

Please sign in to comment.