notedeck

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

commit a555707f677e2a16109ed567304dc9153b3d73d8
parent 1601914b8b7e2b32ab0da81adb7837722735b1a6
Author: kernelkind <kernelkind@gmail.com>
Date:   Thu, 24 Jul 2025 17:35:42 -0400

get scroll id for `Route`

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

Diffstat:
Mcrates/notedeck_columns/src/nav.rs | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 54 insertions(+), 4 deletions(-)

diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs @@ -9,21 +9,22 @@ use crate::{ route::{Route, Router, SingletonRouter}, timeline::{ route::{render_thread_route, render_timeline_route}, - TimelineCache, + TimelineCache, TimelineKind, }, ui::{ self, - add_column::render_add_column_routes, + add_column::{render_add_column_routes, AddColumnView}, column::NavTitle, configure_deck::ConfigureDeckView, edit_deck::{EditDeckResponse, EditDeckView}, - note::{custom_zap::CustomZapView, NewPostAction, PostAction, PostType}, + note::{custom_zap::CustomZapView, NewPostAction, PostAction, PostType, QuoteRepostView}, profile::EditProfileView, search::{FocusState, SearchView}, settings::{SettingsAction, ShowNoteClientOptions}, support::SupportView, wallet::{get_default_zap_state, WalletAction, WalletState, WalletView}, - RelayView, SettingsView, + AccountsView, PostReplyView, PostView, ProfileView, RelayView, SettingsView, ThreadView, + TimelineView, }, Damus, }; @@ -997,3 +998,52 @@ pub fn render_nav( RenderNavResponse::new(col, NotedeckNavResponse::Nav(Box::new(nav_response))) } + +fn get_scroll_id( + top: &Route, + depth: usize, + timeline_cache: &TimelineCache, + col: usize, +) -> Option<egui::Id> { + match top { + Route::Timeline(timeline_kind) => match timeline_kind { + TimelineKind::List(_) + | TimelineKind::Search(_) + | TimelineKind::Algo(_) + | TimelineKind::Notifications(_) + | TimelineKind::Universe + | TimelineKind::Hashtag(_) + | TimelineKind::Generic(_) => { + TimelineView::scroll_id(timeline_cache, timeline_kind, col) + } + TimelineKind::Profile(pubkey) => { + if depth > 1 { + Some(ProfileView::scroll_id(col, pubkey)) + } else { + TimelineView::scroll_id(timeline_cache, timeline_kind, col) + } + } + }, + Route::Thread(thread_selection) => Some(ThreadView::scroll_id( + thread_selection.selected_or_root(), + col, + )), + Route::Accounts(accounts_route) => match accounts_route { + crate::accounts::AccountsRoute::Accounts => Some(AccountsView::scroll_id()), + crate::accounts::AccountsRoute::AddAccount => None, + }, + Route::Reply(note_id) => Some(PostReplyView::scroll_id(col, note_id.bytes())), + Route::Quote(note_id) => Some(QuoteRepostView::scroll_id(col, note_id.bytes())), + Route::Relays => Some(RelayView::scroll_id()), + Route::ComposeNote => Some(PostView::scroll_id()), + Route::AddColumn(add_column_route) => Some(AddColumnView::scroll_id(add_column_route)), + Route::EditProfile(_) => Some(EditProfileView::scroll_id()), + Route::Support => None, + Route::NewDeck => Some(ConfigureDeckView::scroll_id()), + Route::Search => Some(SearchView::scroll_id()), + Route::EditDeck(_) => None, + Route::Wallet(_) => None, + Route::CustomizeZapAmount(_) => None, + Route::Settings => None, + } +}