@@ -70,8 +70,8 @@ pub use wallet::{
|
||||
WalletUIState, ZapWallet,
|
||||
};
|
||||
pub use zaps::{
|
||||
AnyZapState, DefaultZapError, DefaultZapMsats, NoteZapTarget, NoteZapTargetOwned,
|
||||
PendingDefaultZapState, ZapTarget, ZapTargetOwned, ZappingError,
|
||||
get_current_default_msats, AnyZapState, DefaultZapError, DefaultZapMsats, NoteZapTarget,
|
||||
NoteZapTargetOwned, PendingDefaultZapState, ZapTarget, ZapTargetOwned, ZappingError,
|
||||
};
|
||||
|
||||
// export libs
|
||||
|
||||
@@ -33,6 +33,7 @@ pub enum NoteAction {
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub enum ZapAction {
|
||||
Send(ZapTargetAmount),
|
||||
CustomizeAmount(NoteZapTargetOwned),
|
||||
ClearError(NoteZapTargetOwned),
|
||||
}
|
||||
|
||||
|
||||
@@ -7,4 +7,7 @@ pub use cache::{
|
||||
AnyZapState, NoteZapTarget, NoteZapTargetOwned, ZapTarget, ZapTargetOwned, ZappingError, Zaps,
|
||||
};
|
||||
|
||||
pub use default_zap::{DefaultZapError, DefaultZapMsats, PendingDefaultZapState, UserZapMsats};
|
||||
pub use default_zap::{
|
||||
get_current_default_msats, DefaultZapError, DefaultZapMsats, PendingDefaultZapState,
|
||||
UserZapMsats,
|
||||
};
|
||||
|
||||
@@ -97,6 +97,9 @@ fn execute_note_action(
|
||||
)
|
||||
}
|
||||
ZapAction::ClearError(target) => clear_zap_error(&sender, zaps, target),
|
||||
ZapAction::CustomizeAmount(target) => {
|
||||
router.route_to(Route::CustomizeZapAmount(target.to_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::{
|
||||
column::NavTitle,
|
||||
configure_deck::ConfigureDeckView,
|
||||
edit_deck::{EditDeckResponse, EditDeckView},
|
||||
note::{NewPostAction, PostAction, PostType},
|
||||
note::{custom_zap::CustomZapView, NewPostAction, PostAction, PostType},
|
||||
profile::EditProfileView,
|
||||
search::{FocusState, SearchView},
|
||||
support::SupportView,
|
||||
@@ -27,7 +27,10 @@ use crate::{
|
||||
|
||||
use egui_nav::{Nav, NavAction, NavResponse, NavUiType};
|
||||
use nostrdb::Transaction;
|
||||
use notedeck::{get_current_wallet, AccountsAction, AppContext, NoteAction, NoteContext};
|
||||
use notedeck::{
|
||||
get_current_default_msats, get_current_wallet, AccountsAction, AppContext, NoteAction,
|
||||
NoteContext,
|
||||
};
|
||||
use notedeck_ui::View;
|
||||
use tracing::error;
|
||||
|
||||
@@ -292,7 +295,6 @@ fn render_nav_body(
|
||||
&mut note_context,
|
||||
&mut app.jobs,
|
||||
),
|
||||
|
||||
Route::Accounts(amr) => {
|
||||
let mut action = render_accounts_route(
|
||||
ui,
|
||||
@@ -310,13 +312,11 @@ fn render_nav_body(
|
||||
.accounts_action
|
||||
.map(|f| RenderNavAction::SwitchingAction(SwitchingAction::Accounts(f)))
|
||||
}
|
||||
|
||||
Route::Relays => {
|
||||
let manager = RelayPoolManager::new(ctx.pool);
|
||||
RelayView::new(ctx.accounts, manager, &mut app.view_state.id_string_map).ui(ui);
|
||||
None
|
||||
}
|
||||
|
||||
Route::Reply(id) => {
|
||||
let txn = if let Ok(txn) = Transaction::new(ctx.ndb) {
|
||||
txn
|
||||
@@ -359,7 +359,6 @@ fn render_nav_body(
|
||||
|
||||
action.map(Into::into)
|
||||
}
|
||||
|
||||
Route::Quote(id) => {
|
||||
let txn = Transaction::new(ctx.ndb).expect("txn");
|
||||
|
||||
@@ -393,7 +392,6 @@ fn render_nav_body(
|
||||
|
||||
response.action.map(Into::into)
|
||||
}
|
||||
|
||||
Route::ComposeNote => {
|
||||
let kp = ctx.accounts.get_selected_account()?.key.to_full()?;
|
||||
let draft = app.drafts.compose_mut();
|
||||
@@ -412,18 +410,15 @@ fn render_nav_body(
|
||||
|
||||
post_response.action.map(Into::into)
|
||||
}
|
||||
|
||||
Route::AddColumn(route) => {
|
||||
render_add_column_routes(ui, app, ctx, col, route);
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
Route::Support => {
|
||||
SupportView::new(&mut app.support).show(ui);
|
||||
None
|
||||
}
|
||||
|
||||
Route::Search => {
|
||||
let id = ui.id().with(("search", depth, col));
|
||||
let navigating = get_active_columns_mut(ctx.accounts, &mut app.decks_cache)
|
||||
@@ -454,7 +449,6 @@ fn render_nav_body(
|
||||
.show(ui, ctx.clipboard)
|
||||
.map(RenderNavAction::NoteAction)
|
||||
}
|
||||
|
||||
Route::NewDeck => {
|
||||
let id = ui.id().with("new-deck");
|
||||
let new_deck_state = app.view_state.id_to_deck_state.entry(id).or_default();
|
||||
@@ -597,6 +591,30 @@ fn render_nav_body(
|
||||
.ui(ui)
|
||||
.map(RenderNavAction::WalletAction)
|
||||
}
|
||||
Route::CustomizeZapAmount(target) => {
|
||||
let txn = Transaction::new(ctx.ndb).expect("txn");
|
||||
let default_msats = get_current_default_msats(ctx.accounts, ctx.global_wallet);
|
||||
CustomZapView::new(
|
||||
ctx.img_cache,
|
||||
ctx.ndb,
|
||||
&txn,
|
||||
&target.zap_recipient,
|
||||
default_msats,
|
||||
)
|
||||
.ui(ui)
|
||||
.map(|msats| {
|
||||
get_active_columns_mut(ctx.accounts, &mut app.decks_cache)
|
||||
.column_mut(col)
|
||||
.router_mut()
|
||||
.go_back();
|
||||
RenderNavAction::NoteAction(NoteAction::Zap(notedeck::ZapAction::Send(
|
||||
notedeck::note::ZapTargetAmount {
|
||||
target: target.clone(),
|
||||
specified_msats: Some(msats),
|
||||
},
|
||||
)))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use enostr::{NoteId, Pubkey};
|
||||
use notedeck::WalletType;
|
||||
use notedeck::{NoteZapTargetOwned, WalletType};
|
||||
use std::fmt::{self};
|
||||
|
||||
use crate::{
|
||||
@@ -29,6 +29,7 @@ pub enum Route {
|
||||
Search,
|
||||
EditDeck(usize),
|
||||
Wallet(WalletType),
|
||||
CustomizeZapAmount(NoteZapTargetOwned),
|
||||
}
|
||||
|
||||
impl Route {
|
||||
@@ -112,6 +113,7 @@ impl Route {
|
||||
Route::Wallet(_) => {
|
||||
writer.write_token("wallet");
|
||||
}
|
||||
Route::CustomizeZapAmount(_) => writer.write_token("customize zap amount"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,12 +203,9 @@ impl Route {
|
||||
pub fn title(&self) -> ColumnTitle<'_> {
|
||||
match self {
|
||||
Route::Timeline(kind) => kind.to_title(),
|
||||
|
||||
Route::Reply(_id) => ColumnTitle::simple("Reply"),
|
||||
Route::Quote(_id) => ColumnTitle::simple("Quote"),
|
||||
|
||||
Route::Relays => ColumnTitle::simple("Relays"),
|
||||
|
||||
Route::Accounts(amr) => match amr {
|
||||
AccountsRoute::Accounts => ColumnTitle::simple("Accounts"),
|
||||
AccountsRoute::AddAccount => ColumnTitle::simple("Add Account"),
|
||||
@@ -238,6 +237,7 @@ impl Route {
|
||||
Route::EditProfile(_) => ColumnTitle::simple("Edit Profile"),
|
||||
Route::Search => ColumnTitle::simple("Search"),
|
||||
Route::Wallet(_) => ColumnTitle::simple("Wallet"),
|
||||
Route::CustomizeZapAmount(_) => ColumnTitle::simple("Customize Zap Amount"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,18 +342,14 @@ impl fmt::Display for Route {
|
||||
TimelineKind::Thread(_id) => write!(f, "Thread"),
|
||||
TimelineKind::Profile(_id) => write!(f, "Profile"),
|
||||
},
|
||||
|
||||
Route::Reply(_id) => write!(f, "Reply"),
|
||||
Route::Quote(_id) => write!(f, "Quote"),
|
||||
|
||||
Route::Relays => write!(f, "Relays"),
|
||||
|
||||
Route::Accounts(amr) => match amr {
|
||||
AccountsRoute::Accounts => write!(f, "Accounts"),
|
||||
AccountsRoute::AddAccount => write!(f, "Add Account"),
|
||||
},
|
||||
Route::ComposeNote => write!(f, "Compose Note"),
|
||||
|
||||
Route::AddColumn(_) => write!(f, "Add Column"),
|
||||
Route::Support => write!(f, "Support"),
|
||||
Route::NewDeck => write!(f, "Add Deck"),
|
||||
@@ -361,6 +357,7 @@ impl fmt::Display for Route {
|
||||
Route::EditProfile(_) => write!(f, "Edit Profile"),
|
||||
Route::Search => write!(f, "Search"),
|
||||
Route::Wallet(_) => write!(f, "Wallet"),
|
||||
Route::CustomizeZapAmount(_) => write!(f, "Customize Zap Amount"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,7 +447,6 @@ impl<'a> NavTitle<'a> {
|
||||
self.timeline_pfp(ui, kind, pfp_size);
|
||||
}
|
||||
},
|
||||
|
||||
Route::Reply(_) => {}
|
||||
Route::Quote(_) => {}
|
||||
Route::Accounts(_as) => {}
|
||||
@@ -464,6 +463,7 @@ impl<'a> NavTitle<'a> {
|
||||
ui.add(ui::side_panel::search_button());
|
||||
}
|
||||
Route::Wallet(_) => {}
|
||||
Route::CustomizeZapAmount(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -728,6 +728,10 @@ fn render_note_actionbar(
|
||||
crate::show_pointer(ui);
|
||||
}
|
||||
|
||||
if zap_resp.secondary_clicked() {
|
||||
break 's Some(NoteAction::Zap(ZapAction::CustomizeAmount(target)));
|
||||
}
|
||||
|
||||
if !zap_resp.clicked() {
|
||||
break 's None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user