fix missing zap button
Changelog-Fixed: Fix missing zap button
Fixes: 397bfce817 ("add `Accounts` to `NoteContext`")
Fixes: https://github.com/damus-io/notedeck/issues/1021
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -13,9 +13,12 @@ use crate::{
|
||||
|
||||
pub use contents::{render_note_contents, render_note_preview, NoteContents};
|
||||
pub use context::NoteContextButton;
|
||||
use notedeck::get_current_wallet;
|
||||
use notedeck::note::MediaAction;
|
||||
use notedeck::note::ZapTargetAmount;
|
||||
use notedeck::ui::is_narrow;
|
||||
use notedeck::Accounts;
|
||||
use notedeck::GlobalWallet;
|
||||
use notedeck::Images;
|
||||
use notedeck::Localization;
|
||||
pub use options::NoteOptions;
|
||||
@@ -451,18 +454,13 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
note_action = contents.action.or(note_action);
|
||||
|
||||
if self.options().contains(NoteOptions::ActionBar) {
|
||||
let zapper = {
|
||||
let cur_acc = self.note_context.accounts.get_selected_account();
|
||||
let has_wallet = cur_acc.wallet.is_some();
|
||||
|
||||
has_wallet.then_some(Zapper {
|
||||
zaps: self.note_context.zaps,
|
||||
cur_acc: cur_acc.keypair(),
|
||||
})
|
||||
};
|
||||
note_action = render_note_actionbar(
|
||||
ui,
|
||||
zapper,
|
||||
get_zapper(
|
||||
self.note_context.accounts,
|
||||
self.note_context.global_wallet,
|
||||
self.note_context.zaps,
|
||||
),
|
||||
self.note.id(),
|
||||
self.note.pubkey(),
|
||||
note_key,
|
||||
@@ -531,20 +529,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
note_action = contents.action.or(note_action);
|
||||
|
||||
let zapper = {
|
||||
let cur_acc = self.note_context.accounts.get_selected_account();
|
||||
let has_wallet = cur_acc.wallet.is_some();
|
||||
|
||||
has_wallet.then_some(Zapper {
|
||||
zaps: self.note_context.zaps,
|
||||
cur_acc: cur_acc.keypair(),
|
||||
})
|
||||
};
|
||||
|
||||
if self.options().contains(NoteOptions::ActionBar) {
|
||||
note_action = render_note_actionbar(
|
||||
ui,
|
||||
zapper,
|
||||
get_zapper(
|
||||
self.note_context.accounts,
|
||||
self.note_context.global_wallet,
|
||||
self.note_context.zaps,
|
||||
),
|
||||
self.note.id(),
|
||||
self.note.pubkey(),
|
||||
note_key,
|
||||
@@ -611,6 +603,20 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_zapper<'a>(
|
||||
accounts: &'a Accounts,
|
||||
global_wallet: &'a GlobalWallet,
|
||||
zaps: &'a Zaps,
|
||||
) -> Option<Zapper<'a>> {
|
||||
let has_wallet = get_current_wallet(accounts, global_wallet).is_some();
|
||||
let cur_acc = accounts.get_selected_account();
|
||||
|
||||
has_wallet.then_some(Zapper {
|
||||
zaps,
|
||||
cur_acc: cur_acc.keypair(),
|
||||
})
|
||||
}
|
||||
|
||||
fn get_reposted_note<'a>(ndb: &Ndb, txn: &'a Transaction, note: &Note) -> Option<Note<'a>> {
|
||||
if note.kind() != 6 {
|
||||
return None;
|
||||
@@ -769,7 +775,7 @@ struct Zapper<'a> {
|
||||
#[profiling::function]
|
||||
fn render_note_actionbar(
|
||||
ui: &mut egui::Ui,
|
||||
zapper: Option<Zapper>,
|
||||
zapper: Option<Zapper<'_>>,
|
||||
note_id: &[u8; 32],
|
||||
note_pubkey: &[u8; 32],
|
||||
note_key: NoteKey,
|
||||
|
||||
Reference in New Issue
Block a user