notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 89a2e5f6732fab76ccc0d1bdeb8d6e81d299fb0f
parent e47f45e24ace9bd37044e5035373b39220c64f8b
Author: kernelkind <kernelkind@gmail.com>
Date:   Thu, 11 Dec 2025 12:50:50 -0600

refactor(nav): rename BodyResponse -> DragResponse

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/lib.rs | 2+-
Mcrates/notedeck/src/nav.rs | 20++++++++++----------
Mcrates/notedeck_columns/src/accounts/mod.rs | 6+++---
Mcrates/notedeck_columns/src/nav.rs | 38+++++++++++++++++++-------------------
Mcrates/notedeck_columns/src/timeline/route.rs | 8++++----
Mcrates/notedeck_columns/src/ui/accounts.rs | 6+++---
Mcrates/notedeck_columns/src/ui/mentions_picker.rs | 6+++---
Mcrates/notedeck_columns/src/ui/note/post.rs | 12++++++------
Mcrates/notedeck_columns/src/ui/note/quote_repost.rs | 8++++----
Mcrates/notedeck_columns/src/ui/note/reply.rs | 8++++----
Mcrates/notedeck_columns/src/ui/onboarding.rs | 8++++----
Mcrates/notedeck_columns/src/ui/profile/contacts_list.rs | 6+++---
Mcrates/notedeck_columns/src/ui/profile/edit.rs | 6+++---
Mcrates/notedeck_columns/src/ui/profile/mod.rs | 8++++----
Mcrates/notedeck_columns/src/ui/relay.rs | 6+++---
Mcrates/notedeck_columns/src/ui/search/mod.rs | 12++++++------
Mcrates/notedeck_columns/src/ui/settings.rs | 6+++---
Mcrates/notedeck_columns/src/ui/thread.rs | 6+++---
Mcrates/notedeck_columns/src/ui/timeline.rs | 12++++++------
19 files changed, 92 insertions(+), 92 deletions(-)

diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs @@ -68,7 +68,7 @@ pub use media::{ }; pub use muted::{MuteFun, Muted}; pub use name::NostrName; -pub use nav::BodyResponse; +pub use nav::DragResponse; pub use nip51_set::{create_nip51_set, Nip51Set, Nip51SetCache}; pub use note::{ BroadcastContext, ContextSelection, NoteAction, NoteContext, NoteContextSelection, NoteRef, diff --git a/crates/notedeck/src/nav.rs b/crates/notedeck/src/nav.rs @@ -1,11 +1,11 @@ use egui::scroll_area::ScrollAreaOutput; -pub struct BodyResponse<R> { +pub struct DragResponse<R> { pub drag_id: Option<egui::Id>, // the id which was used for dragging. pub output: Option<R>, } -impl<R> BodyResponse<R> { +impl<R> DragResponse<R> { pub fn none() -> Self { Self { drag_id: None, @@ -51,29 +51,29 @@ impl<R> BodyResponse<R> { id.with("area") } - pub fn map_output<S>(self, f: impl FnOnce(R) -> S) -> BodyResponse<S> { - BodyResponse { + pub fn map_output<S>(self, f: impl FnOnce(R) -> S) -> DragResponse<S> { + DragResponse { drag_id: self.drag_id, output: self.output.map(f), } } - pub fn map_output_maybe<S>(self, f: impl FnOnce(R) -> Option<S>) -> BodyResponse<S> { - BodyResponse { + pub fn map_output_maybe<S>(self, f: impl FnOnce(R) -> Option<S>) -> DragResponse<S> { + DragResponse { drag_id: self.drag_id, output: self.output.and_then(f), } } - pub fn maybe_map_output<S>(self, f: impl FnOnce(Option<R>) -> S) -> BodyResponse<S> { - BodyResponse { + pub fn maybe_map_output<S>(self, f: impl FnOnce(Option<R>) -> S) -> DragResponse<S> { + DragResponse { drag_id: self.drag_id, output: Some(f(self.output)), } } - /// insert the contents of the new BodyResponse if they are empty in Self - pub fn insert(&mut self, body: BodyResponse<R>) { + /// insert the contents of the new DragResponse if they are empty in Self + pub fn insert(&mut self, body: DragResponse<R>) { self.drag_id = self.drag_id.or(body.drag_id); if self.output.is_none() { self.output = body.output; diff --git a/crates/notedeck_columns/src/accounts/mod.rs b/crates/notedeck_columns/src/accounts/mod.rs @@ -1,7 +1,7 @@ use enostr::{FullKeypair, Pubkey}; use nostrdb::{Ndb, Transaction}; -use notedeck::{Accounts, AppContext, BodyResponse, Localization, SingleUnkIdAction, UnknownIds}; +use notedeck::{Accounts, AppContext, DragResponse, Localization, SingleUnkIdAction, UnknownIds}; use notedeck_ui::nip51_set::Nip51SetUiCache; pub use crate::accounts::route::AccountsResponse; @@ -80,7 +80,7 @@ pub fn render_accounts_route( onboarding: &mut Onboarding, follow_packs_ui: &mut Nip51SetUiCache, route: AccountsRoute, -) -> BodyResponse<AccountsResponse> { +) -> DragResponse<AccountsResponse> { match route { AccountsRoute::Accounts => AccountsView::new( app_ctx.ndb, @@ -98,7 +98,7 @@ pub fn render_accounts_route( .inner .map(AccountsRouteResponse::AddAccount) .map(AccountsResponse::Account); - BodyResponse::output(action) + DragResponse::output(action) } AccountsRoute::Onboarding => FollowPackOnboardingView::new( onboarding, diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs @@ -38,7 +38,7 @@ use egui_nav::{ use enostr::{ProfileState, RelayPool}; use nostrdb::{Filter, Ndb, Transaction}; use notedeck::{ - get_current_default_msats, nav::BodyResponse, tr, ui::is_narrow, Accounts, AppContext, + get_current_default_msats, nav::DragResponse, tr, ui::is_narrow, Accounts, AppContext, NoteAction, NoteCache, NoteContext, RelayAction, }; use notedeck_ui::NoteOptions; @@ -625,7 +625,7 @@ fn render_nav_body( depth: usize, col: usize, inner_rect: egui::Rect, -) -> BodyResponse<RenderNavAction> { +) -> DragResponse<RenderNavAction> { let mut note_context = NoteContext { ndb: ctx.ndb, accounts: ctx.accounts, @@ -722,7 +722,7 @@ fn render_nav_body( "Reply to unknown note", "Error message when reply note cannot be found" )); - return BodyResponse::none(); + return DragResponse::none(); }; let note = if let Ok(note) = ctx.ndb.get_note_by_id(&txn, id.bytes()) { @@ -733,11 +733,11 @@ fn render_nav_body( "Reply to unknown note", "Error message when reply note cannot be found" )); - return BodyResponse::none(); + return DragResponse::none(); }; let Some(poster) = ctx.accounts.selected_filled() else { - return BodyResponse::none(); + return DragResponse::none(); }; let resp = { @@ -771,11 +771,11 @@ fn render_nav_body( "Quote of unknown note", "Error message when quote note cannot be found" )); - return BodyResponse::none(); + return DragResponse::none(); }; let Some(poster) = ctx.accounts.selected_filled() else { - return BodyResponse::none(); + return DragResponse::none(); }; let draft = app.drafts.quote_mut(note.id()); @@ -795,7 +795,7 @@ fn render_nav_body( } Route::ComposeNote => { let Some(kp) = ctx.accounts.get_selected_account().key.to_full() else { - return BodyResponse::none(); + return DragResponse::none(); }; let navigating = get_active_columns_mut(note_context.i18n, ctx.accounts, &mut app.decks_cache) @@ -826,11 +826,11 @@ fn render_nav_body( Route::AddColumn(route) => { render_add_column_routes(ui, app, ctx, col, route); - BodyResponse::none() + DragResponse::none() } Route::Support => { SupportView::new(&mut app.support, ctx.i18n).show(ui); - BodyResponse::none() + DragResponse::none() } Route::Search => { let id = ui.id().with(("search", depth, col)); @@ -879,7 +879,7 @@ fn render_nav_body( .go_back(); } - BodyResponse::output(resp) + DragResponse::output(resp) } Route::EditDeck(index) => { let mut action = None; @@ -911,19 +911,19 @@ fn render_nav_body( .go_back(); } - BodyResponse::output(action) + DragResponse::output(action) } Route::EditProfile(pubkey) => { let Some(kp) = ctx.accounts.get_full(pubkey) else { error!("Pubkey in EditProfile route did not have an nsec attached in Accounts"); - return BodyResponse::none(); + return DragResponse::none(); }; let Some(state) = app.view_state.pubkey_to_profile_state.get_mut(kp.pubkey) else { tracing::error!( "No profile state when navigating to EditProfile... was handle_navigating_edit_profile not called?" ); - return BodyResponse::none(); + return DragResponse::none(); }; EditProfileView::new( @@ -1007,7 +1007,7 @@ fn render_nav_body( } }) } - Route::FollowedBy(_pubkey) => BodyResponse::none(), + Route::FollowedBy(_pubkey) => DragResponse::none(), Route::Wallet(wallet_type) => { let state = match wallet_type { notedeck::WalletType::Auto => 's: { @@ -1053,13 +1053,13 @@ fn render_nav_body( } }; - BodyResponse::output(WalletView::new(state, ctx.i18n, ctx.clipboard).ui(ui)) + DragResponse::output(WalletView::new(state, ctx.i18n, ctx.clipboard).ui(ui)) .map_output(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); - BodyResponse::output( + DragResponse::output( CustomZapView::new( ctx.i18n, ctx.img_cache, @@ -1085,7 +1085,7 @@ fn render_nav_body( }) } Route::RepostDecision(note_id) => { - BodyResponse::output(RepostDecisionView::new(note_id).show(ui)) + DragResponse::output(RepostDecisionView::new(note_id).show(ui)) .map_output(RenderNavAction::RepostAction) } } @@ -1197,7 +1197,7 @@ pub fn render_nav( let resp = if let Some(top) = nav.routes().last() { render_nav_body(ui, app, ctx, top, nav.routes().len(), col, inner_rect) } else { - BodyResponse::none() + DragResponse::none() }; RouteResponse { diff --git a/crates/notedeck_columns/src/timeline/route.rs b/crates/notedeck_columns/src/timeline/route.rs @@ -6,7 +6,7 @@ use crate::{ }; use enostr::Pubkey; -use notedeck::{BodyResponse, NoteContext}; +use notedeck::{DragResponse, NoteContext}; use notedeck_ui::NoteOptions; #[allow(clippy::too_many_arguments)] @@ -19,7 +19,7 @@ pub fn render_timeline_route( ui: &mut egui::Ui, note_context: &mut NoteContext, scroll_to_top: bool, -) -> BodyResponse<RenderNavAction> { +) -> DragResponse<RenderNavAction> { match kind { TimelineKind::List(_) | TimelineKind::Search(_) @@ -58,7 +58,7 @@ pub fn render_thread_route( mut note_options: NoteOptions, ui: &mut egui::Ui, note_context: &mut NoteContext, -) -> BodyResponse<RenderNavAction> { +) -> DragResponse<RenderNavAction> { // don't truncate thread notes for now, since they are // default truncated everywher eelse note_options.set(NoteOptions::Truncate, false); @@ -85,7 +85,7 @@ pub fn render_profile_route( ui: &mut egui::Ui, note_options: NoteOptions, note_context: &mut NoteContext, -) -> BodyResponse<RenderNavAction> { +) -> DragResponse<RenderNavAction> { let profile_view = ProfileView::new(pubkey, col, timeline_cache, note_options, note_context).ui(ui); diff --git a/crates/notedeck_columns/src/ui/accounts.rs b/crates/notedeck_columns/src/ui/accounts.rs @@ -3,7 +3,7 @@ use egui::{ }; use enostr::Pubkey; use nostrdb::{Ndb, Transaction}; -use notedeck::{tr, Accounts, BodyResponse, Images, Localization, MediaJobSender}; +use notedeck::{tr, Accounts, DragResponse, Images, Localization, MediaJobSender}; use notedeck_ui::colors::PINK; use notedeck_ui::profile::preview::SimpleProfilePreview; @@ -47,8 +47,8 @@ impl<'a> AccountsView<'a> { } } - pub fn ui(&mut self, ui: &mut Ui) -> BodyResponse<AccountsViewResponse> { - let mut out = BodyResponse::none(); + pub fn ui(&mut self, ui: &mut Ui) -> DragResponse<AccountsViewResponse> { + let mut out = DragResponse::none(); Frame::new().outer_margin(12.0).show(ui, |ui| { if let Some(resp) = Self::top_section_buttons_widget(ui, self.i18n).inner { out.set_output(resp); diff --git a/crates/notedeck_columns/src/ui/mentions_picker.rs b/crates/notedeck_columns/src/ui/mentions_picker.rs @@ -1,7 +1,7 @@ use egui::{vec2, FontId, Layout, Pos2, Rect, ScrollArea, UiBuilder, Vec2b}; use nostrdb::{Ndb, ProfileRecord, Transaction}; use notedeck::{ - fonts::get_font_size, name::get_display_name, profile::get_profile_url, BodyResponse, Images, + fonts::get_font_size, name::get_display_name, profile::get_profile_url, DragResponse, Images, MediaJobSender, NotedeckTextStyle, }; use notedeck_ui::{ @@ -71,7 +71,7 @@ impl<'a> MentionPickerView<'a> { &mut self, rect: egui::Rect, ui: &mut egui::Ui, - ) -> BodyResponse<MentionPickerResponse> { + ) -> DragResponse<MentionPickerResponse> { let widget_id = ui.id().with("mention_results"); let area_resp = egui::Area::new(widget_id) .order(egui::Order::Foreground) @@ -112,7 +112,7 @@ impl<'a> MentionPickerView<'a> { .show(ui, |ui| Some(self.show(ui, width))); ui.advance_cursor_after_rect(rect); - BodyResponse::scroll(scroll_resp).map_output(|o| { + DragResponse::scroll(scroll_resp).map_output(|o| { if close_button_resp { MentionPickerResponse::DeleteMention } else { diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs @@ -20,7 +20,7 @@ use notedeck::platform::get_next_selected_file; use notedeck::{ name::get_display_name, supported_mime_hosted_at_url, tr, Localization, NoteAction, NoteContext, }; -use notedeck::{BodyResponse, PixelDimensions}; +use notedeck::{DragResponse, PixelDimensions}; use notedeck_ui::{ app_images, context_menu::{input_context, PasteBehavior}, @@ -363,7 +363,7 @@ impl<'a, 'd> PostView<'a, 'd> { 12 } - pub fn ui(&mut self, txn: &Transaction, ui: &mut egui::Ui) -> BodyResponse<PostResponse> { + pub fn ui(&mut self, txn: &Transaction, ui: &mut egui::Ui) -> DragResponse<PostResponse> { let scroll_out = ScrollArea::vertical() .id_salt(PostView::scroll_id()) .show(ui, |ui| Some(self.ui_no_scroll(txn, ui))); @@ -372,7 +372,7 @@ impl<'a, 'd> PostView<'a, 'd> { if let Some(inner) = scroll_out.inner { inner // should override the PostView scroll for the mention scroll } else { - BodyResponse::none() + DragResponse::none() } .scroll_raw(scroll_id) } @@ -381,7 +381,7 @@ impl<'a, 'd> PostView<'a, 'd> { &mut self, txn: &Transaction, ui: &mut egui::Ui, - ) -> BodyResponse<PostResponse> { + ) -> DragResponse<PostResponse> { while let Some(selected_file) = get_next_selected_file() { match selected_file { Ok(selected_media) => { @@ -426,7 +426,7 @@ impl<'a, 'd> PostView<'a, 'd> { .inner } - fn input_ui(&mut self, txn: &Transaction, ui: &mut egui::Ui) -> BodyResponse<PostResponse> { + fn input_ui(&mut self, txn: &Transaction, ui: &mut egui::Ui) -> DragResponse<PostResponse> { let edit_response = ui.horizontal(|ui| self.editbox(txn, ui)).inner; let note_response = if let PostType::Quote(id) = self.post_type { @@ -477,7 +477,7 @@ impl<'a, 'd> PostView<'a, 'd> { .and_then(|nr| nr.action.map(PostAction::QuotedNoteAction)) .or(post_action.map(PostAction::NewPostAction)); - let mut resp = BodyResponse::output(action); + let mut resp = DragResponse::output(action); if let Some(drag_id) = edit_response.mention_hints_drag_id { resp.set_drag_id_raw(drag_id); } diff --git a/crates/notedeck_columns/src/ui/note/quote_repost.rs b/crates/notedeck_columns/src/ui/note/quote_repost.rs @@ -6,7 +6,7 @@ use crate::{ use egui::ScrollArea; use enostr::{FilledKeypair, NoteId}; -use notedeck::{BodyResponse, NoteContext}; +use notedeck::{DragResponse, NoteContext}; use notedeck_ui::NoteOptions; pub struct QuoteRepostView<'a, 'd> { @@ -49,7 +49,7 @@ impl<'a, 'd> QuoteRepostView<'a, 'd> { QuoteRepostView::id(col, note_id).with("scroll") } - pub fn show(&mut self, ui: &mut egui::Ui) -> BodyResponse<PostResponse> { + pub fn show(&mut self, ui: &mut egui::Ui) -> DragResponse<PostResponse> { let scroll_out = ScrollArea::vertical() .id_salt(self.scroll_id) .show(ui, |ui| Some(self.show_internal(ui))); @@ -59,12 +59,12 @@ impl<'a, 'd> QuoteRepostView<'a, 'd> { if let Some(inner) = scroll_out.inner { inner } else { - BodyResponse::none() + DragResponse::none() } .scroll_raw(scroll_id) } - fn show_internal(&mut self, ui: &mut egui::Ui) -> BodyResponse<PostResponse> { + fn show_internal(&mut self, ui: &mut egui::Ui) -> DragResponse<PostResponse> { let quoting_note_id = self.quoting_note.id(); let post_resp = ui::PostView::new( diff --git a/crates/notedeck_columns/src/ui/note/reply.rs b/crates/notedeck_columns/src/ui/note/reply.rs @@ -6,7 +6,7 @@ use crate::ui::{ use egui::{Rect, Response, ScrollArea, Ui}; use enostr::{FilledKeypair, NoteId}; -use notedeck::{BodyResponse, NoteContext}; +use notedeck::{DragResponse, NoteContext}; use notedeck_ui::{NoteOptions, NoteView, ProfilePic}; pub struct PostReplyView<'a, 'd> { @@ -49,7 +49,7 @@ impl<'a, 'd> PostReplyView<'a, 'd> { PostReplyView::id(col, note_id).with("scroll") } - pub fn show(&mut self, ui: &mut egui::Ui) -> BodyResponse<PostResponse> { + pub fn show(&mut self, ui: &mut egui::Ui) -> DragResponse<PostResponse> { let scroll_out = ScrollArea::vertical() .id_salt(self.scroll_id) .stick_to_bottom(true) @@ -59,13 +59,13 @@ impl<'a, 'd> PostReplyView<'a, 'd> { if let Some(inner) = scroll_out.inner { inner } else { - BodyResponse::none() + DragResponse::none() } .scroll_raw(scroll_id) } // no scroll - fn show_internal(&mut self, ui: &mut egui::Ui) -> BodyResponse<PostResponse> { + fn show_internal(&mut self, ui: &mut egui::Ui) -> DragResponse<PostResponse> { ui.vertical(|ui| { let avail_rect = ui.available_rect_before_wrap(); diff --git a/crates/notedeck_columns/src/ui/onboarding.rs b/crates/notedeck_columns/src/ui/onboarding.rs @@ -2,7 +2,7 @@ use std::mem; use egui::{Layout, ScrollArea}; use nostrdb::Ndb; -use notedeck::{tr, BodyResponse, Images, Localization, MediaJobSender}; +use notedeck::{tr, DragResponse, Images, Localization, MediaJobSender}; use notedeck_ui::{ colors, nip51_set::{Nip51SetUiCache, Nip51SetWidget, Nip51SetWidgetAction, Nip51SetWidgetFlags}, @@ -53,9 +53,9 @@ impl<'a> FollowPackOnboardingView<'a> { egui::Id::new("follow_pack_onboarding") } - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<OnboardingResponse> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<OnboardingResponse> { let Some(follow_pack_state) = self.onboarding.get_follow_packs() else { - return BodyResponse::output(Some(OnboardingResponse::FollowPacks( + return DragResponse::output(Some(OnboardingResponse::FollowPacks( FollowPacksResponse::NoFollowPacks, ))); }; @@ -110,6 +110,6 @@ impl<'a> FollowPackOnboardingView<'a> { } }); - BodyResponse::output(action).scroll_raw(scroll_out.id) + DragResponse::output(action).scroll_raw(scroll_out.id) } } diff --git a/crates/notedeck_columns/src/ui/profile/contacts_list.rs b/crates/notedeck_columns/src/ui/profile/contacts_list.rs @@ -1,7 +1,7 @@ use egui::{RichText, Sense}; use enostr::Pubkey; use nostrdb::Transaction; -use notedeck::{name::get_display_name, profile::get_profile_url, BodyResponse, NoteContext}; +use notedeck::{name::get_display_name, profile::get_profile_url, DragResponse, NoteContext}; use notedeck_ui::ProfilePic; pub struct ContactsListView<'a, 'd, 'txn> { @@ -29,7 +29,7 @@ impl<'a, 'd, 'txn> ContactsListView<'a, 'd, 'txn> { } } - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<ContactsListAction> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<ContactsListAction> { let mut action = None; egui::ScrollArea::vertical().show(ui, |ui| { @@ -91,6 +91,6 @@ impl<'a, 'd, 'txn> ContactsListView<'a, 'd, 'txn> { } }); - BodyResponse::output(action) + DragResponse::output(action) } } diff --git a/crates/notedeck_columns/src/ui/profile/edit.rs b/crates/notedeck_columns/src/ui/profile/edit.rs @@ -3,7 +3,7 @@ use core::f32; use egui::{vec2, Button, CornerRadius, Layout, Margin, RichText, ScrollArea, TextEdit}; use egui_winit::clipboard::Clipboard; use enostr::ProfileState; -use notedeck::BodyResponse; +use notedeck::DragResponse; use notedeck::{ profile::unwrap_profile_url, tr, Images, Localization, MediaJobSender, NotedeckTextStyle, }; @@ -40,7 +40,7 @@ impl<'a> EditProfileView<'a> { } // return true to save - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<bool> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<bool> { let scroll_out = ScrollArea::vertical() .id_salt(EditProfileView::scroll_id()) .stick_to_bottom(true) @@ -79,7 +79,7 @@ impl<'a> EditProfileView<'a> { Some(save) }); - BodyResponse::scroll(scroll_out) + DragResponse::scroll(scroll_out) } fn inner(&mut self, ui: &mut egui::Ui, padding: f32) { diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -6,7 +6,7 @@ pub use edit::EditProfileView; use egui::{vec2, Color32, CornerRadius, Layout, Rect, RichText, ScrollArea, Sense, Stroke}; use enostr::Pubkey; use nostrdb::{ProfileRecord, Transaction}; -use notedeck::{tr, BodyResponse, Localization, ProfileContext}; +use notedeck::{tr, DragResponse, Localization, ProfileContext}; use notedeck_ui::profile::{context::ProfileContextWidget, follow_button}; use robius_open::Uri; use tracing::error; @@ -70,7 +70,7 @@ impl<'a, 'd> ProfileView<'a, 'd> { egui::Id::new(("profile_scroll", col_id, profile_pubkey)) } - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<ProfileViewAction> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<ProfileViewAction> { let scroll_id = ProfileView::scroll_id(self.col_id, self.pubkey); let scroll_area = ScrollArea::vertical().id_salt(scroll_id).animated(false); @@ -78,7 +78,7 @@ impl<'a, 'd> ProfileView<'a, 'd> { .timeline_cache .get_mut(&TimelineKind::Profile(*self.pubkey)) else { - return BodyResponse::none(); + return DragResponse::none(); }; let output = scroll_area.show(ui, |ui| { @@ -136,7 +136,7 @@ impl<'a, 'd> ProfileView<'a, 'd> { // only allow front insert when the profile body is fully obstructed profile_timeline.enable_front_insert = output.inner.body_end_pos < ui.clip_rect().top(); - BodyResponse::output(output.inner.action).scroll_raw(output.id) + DragResponse::output(output.inner.action).scroll_raw(output.id) } } diff --git a/crates/notedeck_columns/src/ui/relay.rs b/crates/notedeck_columns/src/ui/relay.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::ui::{Preview, PreviewConfig}; use egui::{Align, Button, CornerRadius, Frame, Id, Layout, Margin, Rgba, RichText, Ui, Vec2}; use enostr::{RelayPool, RelayStatus}; -use notedeck::{tr, BodyResponse, Localization, NotedeckTextStyle, RelayAction}; +use notedeck::{tr, DragResponse, Localization, NotedeckTextStyle, RelayAction}; use notedeck_ui::app_images; use notedeck_ui::{colors::PINK, padding}; use tracing::debug; @@ -17,7 +17,7 @@ pub struct RelayView<'a> { } impl RelayView<'_> { - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<RelayAction> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<RelayAction> { let scroll_out = Frame::new() .inner_margin(Margin::symmetric(10, 0)) .show(ui, |ui| { @@ -52,7 +52,7 @@ impl RelayView<'_> { }) .inner; - BodyResponse::scroll(scroll_out) + DragResponse::scroll(scroll_out) } pub fn scroll_id() -> egui::Id { diff --git a/crates/notedeck_columns/src/ui/search/mod.rs b/crates/notedeck_columns/src/ui/search/mod.rs @@ -10,7 +10,7 @@ use egui_winit::clipboard::Clipboard; use nostrdb::{Filter, Ndb, ProfileRecord, Transaction}; use notedeck::{ fonts::get_font_size, name::get_display_name, profile::get_profile_url, tr, tr_plural, - BodyResponse, Images, Localization, MediaJobSender, NoteAction, NoteContext, NoteRef, + DragResponse, Images, Localization, MediaJobSender, NoteAction, NoteContext, NoteRef, NotedeckTextStyle, }; @@ -50,7 +50,7 @@ impl<'a, 'd> SearchView<'a, 'd> { } } - pub fn show(&mut self, ui: &mut egui::Ui) -> BodyResponse<NoteAction> { + pub fn show(&mut self, ui: &mut egui::Ui) -> DragResponse<NoteAction> { padding(8.0, ui, |ui| self.show_impl(ui)) .inner .map_output(|action| match action { @@ -59,7 +59,7 @@ impl<'a, 'd> SearchView<'a, 'd> { }) } - fn show_impl(&mut self, ui: &mut egui::Ui) -> BodyResponse<SearchViewAction> { + fn show_impl(&mut self, ui: &mut egui::Ui) -> DragResponse<SearchViewAction> { ui.spacing_mut().item_spacing = egui::vec2(0.0, 12.0); let search_resp = search_box( @@ -79,7 +79,7 @@ impl<'a, 'd> SearchView<'a, 'd> { ); let mut search_action = None; - let mut body_resp = BodyResponse::none(); + let mut body_resp = DragResponse::none(); match &self.query.state { SearchState::New | SearchState::Navigating @@ -345,7 +345,7 @@ impl<'a, 'd> SearchView<'a, 'd> { None } - fn show_search_results(&mut self, ui: &mut egui::Ui) -> BodyResponse<NoteAction> { + fn show_search_results(&mut self, ui: &mut egui::Ui) -> DragResponse<NoteAction> { let scroll_out = egui::ScrollArea::vertical() .id_salt(SearchView::scroll_id()) .show(ui, |ui| { @@ -358,7 +358,7 @@ impl<'a, 'd> SearchView<'a, 'd> { .show(ui) }); - BodyResponse::scroll(scroll_out) + DragResponse::scroll(scroll_out) } pub fn scroll_id() -> egui::Id { diff --git a/crates/notedeck_columns/src/ui/settings.rs b/crates/notedeck_columns/src/ui/settings.rs @@ -6,7 +6,7 @@ use egui_extras::{Size, StripBuilder}; use enostr::NoteId; use nostrdb::Transaction; use notedeck::{ - tr, ui::richtext_small, BodyResponse, Images, LanguageIdentifier, Localization, NoteContext, + tr, ui::richtext_small, DragResponse, Images, LanguageIdentifier, Localization, NoteContext, NotedeckTextStyle, Settings, SettingsHandler, DEFAULT_MAX_HASHTAGS_PER_NOTE, DEFAULT_NOTE_BODY_FONT_SIZE, }; @@ -709,7 +709,7 @@ impl<'a> SettingsView<'a> { action } - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<SettingsAction> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<SettingsAction> { let scroll_out = Frame::default() .inner_margin(Margin::symmetric(10, 10)) .show(ui, |ui| { @@ -745,7 +745,7 @@ impl<'a> SettingsView<'a> { }) .inner; - BodyResponse::scroll(scroll_out) + DragResponse::scroll(scroll_out) } } diff --git a/crates/notedeck_columns/src/ui/thread.rs b/crates/notedeck_columns/src/ui/thread.rs @@ -7,7 +7,7 @@ use notedeck_ui::note::NoteResponse; use notedeck_ui::{NoteOptions, NoteView}; use crate::timeline::thread::{NoteSeenFlags, ParentState, Threads}; -use notedeck::BodyResponse; +use notedeck::DragResponse; pub struct ThreadView<'a, 'd> { threads: &'a mut Threads, @@ -39,7 +39,7 @@ impl<'a, 'd> ThreadView<'a, 'd> { egui::Id::new(("threadscroll", selected_note_id, col)) } - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<NoteAction> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<NoteAction> { let txn = Transaction::new(self.note_context.ndb).expect("txn"); let scroll_id = ThreadView::scroll_id(self.selected_note_id, self.col); @@ -69,7 +69,7 @@ impl<'a, 'd> ThreadView<'a, 'd> { *scroll_offset = output.state.offset.y; } - BodyResponse::output(resp).scroll_raw(out_id) + DragResponse::output(resp).scroll_raw(out_id) } fn notes(&mut self, ui: &mut egui::Ui, txn: &Transaction) -> Option<NoteAction> { diff --git a/crates/notedeck_columns/src/ui/timeline.rs b/crates/notedeck_columns/src/ui/timeline.rs @@ -16,7 +16,7 @@ use crate::timeline::{ CompositeType, CompositeUnit, NoteUnit, ReactionUnit, RepostUnit, TimelineCache, TimelineKind, TimelineTab, }; -use notedeck::BodyResponse; +use notedeck::DragResponse; use notedeck::{ note::root_note_id_from_selected_id, tr, Localization, NoteAction, NoteContext, ScrollInfo, }; @@ -54,7 +54,7 @@ impl<'a, 'd> TimelineView<'a, 'd> { } } - pub fn ui(&mut self, ui: &mut egui::Ui) -> BodyResponse<NoteAction> { + pub fn ui(&mut self, ui: &mut egui::Ui) -> DragResponse<NoteAction> { timeline_ui( ui, self.timeline_id, @@ -91,7 +91,7 @@ fn timeline_ui( note_context: &mut NoteContext, col: usize, scroll_to_top: bool, -) -> BodyResponse<NoteAction> { +) -> DragResponse<NoteAction> { //padding(4.0, ui, |ui| ui.heading("Notifications")); /* let font_id = egui::TextStyle::Body.resolve(ui.style()); @@ -100,7 +100,7 @@ fn timeline_ui( */ let Some(scroll_id) = TimelineView::scroll_id(timeline_cache, timeline_id, col) else { - return BodyResponse::none(); + return DragResponse::none(); }; { @@ -110,7 +110,7 @@ fn timeline_ui( error!("tried to render timeline in column, but timeline was missing"); // TODO (jb55): render error when timeline is missing? // this shouldn't happen... - return BodyResponse::none(); + return DragResponse::none(); }; timeline.selected_view = tabs_ui( @@ -211,7 +211,7 @@ fn timeline_ui( } }); - BodyResponse::output(action).scroll_raw(scroll_id) + DragResponse::output(action).scroll_raw(scroll_id) } fn goto_top_button(center: Pos2) -> impl egui::Widget {