Merge remote-tracking branch 'github/pr/1023'

This commit is contained in:
William Casarin
2025-07-23 12:31:51 -07:00
10 changed files with 65 additions and 30 deletions

View File

@@ -20,8 +20,13 @@ pub fn hover_expand(
(rect, size, response)
}
#[inline]
pub fn hover_small_size() -> f32 {
14.0
}
pub fn hover_expand_small(ui: &mut egui::Ui, id: egui::Id) -> (egui::Rect, f32, egui::Response) {
let size = 10.0;
let size = hover_small_size();
let expand_size = 5.0;
let anim_speed = 0.05;

View File

@@ -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,15 +775,19 @@ 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,
i18n: &mut Localization,
) -> egui::InnerResponse<Option<NoteAction>> {
ui.horizontal(|ui| {
ui.set_min_height(26.0);
ui.spacing_mut().item_spacing.x = 24.0;
let reply_resp =
reply_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
let quote_resp =
quote_repost_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
@@ -893,7 +903,7 @@ fn quote_repost_button(
i18n: &mut Localization,
note_key: NoteKey,
) -> egui::Response {
let size = 14.0;
let size = crate::anim::hover_small_size() + 4.0;
let expand_size = 5.0;
let anim_speed = 0.05;
let id = ui.id().with(("repost_anim", note_key));