@@ -20,6 +20,7 @@ use crate::{
|
||||
profile::EditProfileView,
|
||||
search::{FocusState, SearchView},
|
||||
support::SupportView,
|
||||
wallet::{WalletAction, WalletView},
|
||||
RelayView, View,
|
||||
},
|
||||
Damus,
|
||||
@@ -27,7 +28,7 @@ use crate::{
|
||||
|
||||
use egui_nav::{Nav, NavAction, NavResponse, NavUiType};
|
||||
use nostrdb::Transaction;
|
||||
use notedeck::{AccountsAction, AppContext};
|
||||
use notedeck::{AccountsAction, AppContext, WalletState};
|
||||
use tracing::error;
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
@@ -38,6 +39,7 @@ pub enum RenderNavAction {
|
||||
NoteAction(NoteAction),
|
||||
ProfileAction(ProfileAction),
|
||||
SwitchingAction(SwitchingAction),
|
||||
WalletAction(WalletAction),
|
||||
}
|
||||
|
||||
pub enum SwitchingAction {
|
||||
@@ -194,6 +196,12 @@ impl RenderNavResponse {
|
||||
.router_mut(),
|
||||
);
|
||||
}
|
||||
RenderNavAction::WalletAction(wallet_action) => {
|
||||
let router = get_active_columns_mut(ctx.accounts, &mut app.decks_cache)
|
||||
.column_mut(col)
|
||||
.router_mut();
|
||||
wallet_action.process(ctx.accounts, ctx.global_wallet, router)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,6 +523,55 @@ fn render_nav_body(
|
||||
}
|
||||
action
|
||||
}
|
||||
Route::Wallet(wallet_type) => {
|
||||
let state = match wallet_type {
|
||||
notedeck::WalletType::Auto => 's: {
|
||||
if let Some(cur_acc) = ctx.accounts.get_selected_account_mut() {
|
||||
if let Some(wallet) = &mut cur_acc.wallet {
|
||||
break 's WalletState::Wallet {
|
||||
wallet,
|
||||
can_create_local_wallet: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let Some(wallet) = &mut ctx.global_wallet.wallet else {
|
||||
break 's WalletState::NoWallet {
|
||||
state: &mut ctx.global_wallet.ui_state,
|
||||
show_local_only: true,
|
||||
};
|
||||
};
|
||||
|
||||
WalletState::Wallet {
|
||||
wallet,
|
||||
can_create_local_wallet: true,
|
||||
}
|
||||
}
|
||||
notedeck::WalletType::Local => 's: {
|
||||
let Some(cur_acc) = ctx.accounts.get_selected_account_mut() else {
|
||||
break 's WalletState::NoWallet {
|
||||
state: &mut ctx.global_wallet.ui_state,
|
||||
show_local_only: false,
|
||||
};
|
||||
};
|
||||
let Some(wallet) = &mut cur_acc.wallet else {
|
||||
break 's WalletState::NoWallet {
|
||||
state: &mut ctx.global_wallet.ui_state,
|
||||
show_local_only: false,
|
||||
};
|
||||
};
|
||||
|
||||
WalletState::Wallet {
|
||||
wallet,
|
||||
can_create_local_wallet: false,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
WalletView::new(state)
|
||||
.ui(ui)
|
||||
.map(RenderNavAction::WalletAction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use enostr::{NoteId, Pubkey};
|
||||
use notedeck::WalletType;
|
||||
use std::fmt::{self};
|
||||
|
||||
use crate::{
|
||||
@@ -27,6 +28,7 @@ pub enum Route {
|
||||
NewDeck,
|
||||
Search,
|
||||
EditDeck(usize),
|
||||
Wallet(WalletType),
|
||||
}
|
||||
|
||||
impl Route {
|
||||
@@ -107,6 +109,9 @@ impl Route {
|
||||
writer.write_token("deck");
|
||||
writer.write_token("new");
|
||||
}
|
||||
Route::Wallet(_) => {
|
||||
writer.write_token("wallet");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +237,7 @@ impl Route {
|
||||
Route::EditDeck(_) => ColumnTitle::simple("Edit Deck"),
|
||||
Route::EditProfile(_) => ColumnTitle::simple("Edit Profile"),
|
||||
Route::Search => ColumnTitle::simple("Search"),
|
||||
Route::Wallet(_) => ColumnTitle::simple("Wallet"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,6 +360,7 @@ impl fmt::Display for Route {
|
||||
Route::EditDeck(_) => write!(f, "Edit Deck"),
|
||||
Route::EditProfile(_) => write!(f, "Edit Profile"),
|
||||
Route::Search => write!(f, "Search"),
|
||||
Route::Wallet(_) => write!(f, "Wallet"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,6 +464,7 @@ impl<'a> NavTitle<'a> {
|
||||
Route::Search => {
|
||||
ui.add(ui::side_panel::search_button());
|
||||
}
|
||||
Route::Wallet(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ impl WalletAction {
|
||||
&self,
|
||||
accounts: &mut Accounts,
|
||||
global_wallet: &mut GlobalWallet,
|
||||
_router: &mut Router<Route>,
|
||||
router: &mut Router<Route>,
|
||||
) {
|
||||
match &self {
|
||||
WalletAction::SaveURI => {
|
||||
@@ -53,7 +53,7 @@ impl WalletAction {
|
||||
}
|
||||
}
|
||||
WalletAction::AddLocalOnly => {
|
||||
// router.route_to(Route::Wallet(notedeck::WalletType::Local));
|
||||
router.route_to(Route::Wallet(notedeck::WalletType::Local));
|
||||
global_wallet.ui_state.for_local_only = true;
|
||||
}
|
||||
WalletAction::Delete => {
|
||||
|
||||
Reference in New Issue
Block a user