Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ egui-winit = { version = "0.31.1", features = ["android-game-activity", "clipboa
egui_nav = { git = "https://github.com/damus-io/egui-nav", rev = "8767df4bc8d12a90fbcee7493d9c9604fe30f1a2" }
egui_tabs = { git = "https://github.com/damus-io/egui-tabs", rev = "6eb91740577b374a8a6658c09c9a4181299734d0" }
#egui_virtual_list = "0.6.0"
egui_virtual_list = { git = "https://github.com/jb55/hello_egui", rev = "a66b6794f5e707a2f4109633770e02b02fb722e1" }
egui_virtual_list = { git = "https://github.com/kernelkind/hello_egui", rev = "542e6747703cf648bb462ec55f0f885fd37cf0b0" }
ehttp = "0.5.0"
enostr = { path = "crates/enostr" }
ewebsock = { version = "0.2.0", features = ["tls"] }
Expand Down
8 changes: 4 additions & 4 deletions crates/notedeck/src/note/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ pub enum NoteAction {
Profile(Pubkey),

/// User has clicked a note link
Note {
Note { note_id: NoteId, preview: bool },

ThreadAutoUnfold {
note_id: NoteId,
preview: bool,
scroll_offset: f32,
scroll_to: Option<NoteId>,
},

/// User has selected some context option
Expand All @@ -48,7 +49,6 @@ impl NoteAction {
NoteAction::Note {
note_id: id,
preview: false,
scroll_offset: 0.0,
}
}
}
Expand Down
23 changes: 17 additions & 6 deletions crates/notedeck_columns/src/actionbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,23 @@ fn execute_note_action(
.open(ndb, note_cache, txn, pool, &kind)
.map(NotesOpenResult::Timeline);
}
NoteAction::Note {
note_id,
preview,
scroll_offset,
} => 'ex: {
NoteAction::Note { note_id, preview } => 'ex: {
let Ok(thread_selection) = ThreadSelection::from_note_id(ndb, note_cache, txn, note_id)
else {
tracing::error!("No thread selection for {}?", hex::encode(note_id.bytes()));
break 'ex;
};

tracing::info!("Opening thread: {thread_selection:?}");
timeline_res = threads
.open(
ndb,
txn,
pool,
&thread_selection,
Some(note_id),
preview,
col,
scroll_offset,
)
.map(NotesOpenResult::Thread);

Expand Down Expand Up @@ -192,6 +189,20 @@ fn execute_note_action(

media_action.process_default_media_actions(images)
}
NoteAction::ThreadAutoUnfold { note_id, scroll_to } => 's: {
let Ok(thread_selection) = ThreadSelection::from_note_id(ndb, note_cache, txn, note_id)
else {
tracing::error!("No thread selection for {}?", hex::encode(note_id.bytes()));
break 's;
};
timeline_res = threads
.open(ndb, txn, pool, &thread_selection, scroll_to, false, col)
.map(NotesOpenResult::Thread);

router_action = Some(RouterAction::RouteInstantly(Route::Thread(
thread_selection,
)));
}
}

NoteActionResponse {
Expand Down
5 changes: 5 additions & 0 deletions crates/notedeck_columns/src/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ pub enum RouterAction {
/// information about the pfp since we only use it for toggling the
/// chrome atm
PfpClicked,
RouteInstantly(Route),
RouteTo(Route, RouterType),
CloseSheetThenRoute(Route),
Overlay {
Expand Down Expand Up @@ -439,6 +440,10 @@ impl RouterAction {
sheet_router.after_action = Some(route);
None
}
RouterAction::RouteInstantly(route) => {
stack_router.route_instantly(route);
None
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions crates/notedeck_columns/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ impl<R: Clone> Router<R> {
self.routes.push(route);
}

pub fn route_instantly(&mut self, route: R) {
if self.routes.pop().is_none() {
return;
}

self.routes.push(route);
}

/// Go back, start the returning process
pub fn go_back(&mut self) -> Option<R> {
if self.returning || self.routes.len() == 1 {
Expand Down
51 changes: 40 additions & 11 deletions crates/notedeck_columns/src/timeline/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub struct ThreadNode {
pub prev: ParentState,
pub have_all_ancestors: bool,
pub list: VirtualList,
pub set_scroll_offset: Option<f32>,
}

#[derive(Clone)]
Expand All @@ -34,19 +33,15 @@ pub enum ParentState {

impl ThreadNode {
pub fn new(parent: ParentState) -> Self {
let mut list = VirtualList::new();
list.hide_on_resize(None);
Self {
replies: SingleNoteUnits::new(true),
prev: parent,
have_all_ancestors: false,
list: VirtualList::new(),
set_scroll_offset: None,
list,
}
}

pub fn with_offset(mut self, offset: f32) -> Self {
self.set_scroll_offset = Some(offset);
self
}
}

#[derive(Default)]
Expand All @@ -55,6 +50,18 @@ pub struct Threads {
pub subs: ThreadSubs,

pub seen_flags: NoteSeenFlags,
pub scroll_to: Option<ScrollToNote>,
}

pub struct ScrollToNote {
pub id: NoteId,
pub active: bool,
}

impl ScrollToNote {
pub fn new(id: NoteId) -> Self {
Self { id, active: true }
}
}

impl Threads {
Expand All @@ -67,11 +74,14 @@ impl Threads {
txn: &Transaction,
pool: &mut RelayPool,
thread: &ThreadSelection,
scroll_to: Option<NoteId>,
new_scope: bool,
col: usize,
scroll_offset: f32,
) -> Option<NewThreadNotes> {
tracing::info!("Opening thread: {:?}", thread);
if let Some(scroll_to) = scroll_to {
self.scroll_to = Some(ScrollToNote::new(scroll_to));
}

let local_sub_filter = if let Some(selected) = &thread.selected_note {
vec![direct_replies_filter_non_root(
selected.bytes(),
Expand Down Expand Up @@ -99,7 +109,7 @@ impl Threads {
RawEntryMut::Vacant(entry) => {
let id = NoteId::new(*selected_note_id);

let node = ThreadNode::new(ParentState::Unknown).with_offset(scroll_offset);
let node = ThreadNode::new(ParentState::Unknown);
entry.insert(id, node);

&local_sub_filter
Expand Down Expand Up @@ -154,12 +164,23 @@ impl Threads {
.cached_note_or_insert_mut(selected_key, selected)
.reply;

let have_all_ancestors_before = self
.threads
.get(&selected.id())
.map(|t| t.have_all_ancestors)
.unwrap_or(true);
self.fill_reply_chain_recursive(selected, &reply, note_cache, ndb, txn, unknown_ids);
let node = self
.threads
.get_mut(&selected.id())
.expect("should be guarenteed to exist from `Self::fill_reply_chain_recursive`");

if have_all_ancestors_before != node.have_all_ancestors {
if let Some(scroll_to) = self.scroll_to.as_mut() {
scroll_to.active = true;
}
}

let Some(sub) = self.subs.get_local(col) else {
tracing::error!("Was expecting to find local sub");
return;
Expand Down Expand Up @@ -423,4 +444,12 @@ impl SingleNoteUnits {
pub fn contains_key(&self, k: &NoteKey) -> bool {
self.units.contains_key(&UnitKey::Single(*k))
}

pub fn len(&self) -> usize {
self.units.len()
}

pub fn is_empty(&self) -> bool {
self.units.is_empty()
}
}
Loading