Skip to content

Commit 506b848

Browse files
feat(columns): (ctrl | command + click open new column) hashtag, mention, embedded note, profile pic, reply, quote
1 parent 6a08d4b commit 506b848

File tree

17 files changed

+453
-75
lines changed

17 files changed

+453
-75
lines changed

crates/notedeck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub use muted::{MuteFun, Muted};
6767
pub use name::NostrName;
6868
pub use note::{
6969
BroadcastContext, ContextSelection, NoteAction, NoteContext, NoteContextSelection, NoteRef,
70-
RootIdError, RootNoteId, RootNoteIdBuf, ScrollInfo, ZapAction,
70+
OpenColumnInfo, RootIdError, RootNoteId, RootNoteIdBuf, ScrollInfo, ZapAction,
7171
};
7272
pub use notecache::{CachedNote, NoteCache};
7373
pub use options::NotedeckOptions;

crates/notedeck/src/note/action.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,29 @@ pub struct ScrollInfo {
99
pub offset: Vec2,
1010
}
1111

12+
#[derive(Debug, PartialEq)]
13+
pub enum OpenColumnInfo {
14+
/// User has clicked the quote reply action
15+
Reply(NoteId),
16+
17+
/// User has clicked the quote repost action
18+
Quote(NoteId),
19+
20+
/// User has clicked a hashtag
21+
Hashtag(String),
22+
23+
/// User has clicked a profile
24+
Profile(Pubkey),
25+
26+
Note {
27+
note_id: NoteId,
28+
},
29+
}
30+
1231
#[derive(Debug)]
1332
pub enum NoteAction {
33+
MissingThreadSub,
34+
1435
/// User has clicked the quote reply action
1536
Reply(NoteId),
1637

@@ -24,7 +45,10 @@ pub enum NoteAction {
2445
Profile(Pubkey),
2546

2647
/// User has clicked a note link
27-
Note { note_id: NoteId, preview: bool },
48+
Note {
49+
note_id: NoteId,
50+
preview: bool,
51+
},
2852

2953
/// User has selected some context option
3054
Context(ContextSelection),
@@ -37,6 +61,8 @@ pub enum NoteAction {
3761

3862
/// User scrolled the timeline
3963
Scroll(ScrollInfo),
64+
65+
OpenColumn(OpenColumnInfo),
4066
}
4167

4268
impl NoteAction {

crates/notedeck/src/note/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod action;
22
mod context;
33

4-
pub use action::{NoteAction, ScrollInfo, ZapAction, ZapTargetAmount};
4+
pub use action::{NoteAction, OpenColumnInfo, ScrollInfo, ZapAction, ZapTargetAmount};
55
pub use context::{BroadcastContext, ContextSelection, NoteContextSelection};
66

77
use crate::Accounts;

crates/notedeck_chrome/src/chrome.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ impl ChromePanelAction {
101101
chrome.switch_to_columns();
102102

103103
if let Some(c) = chrome.get_columns_app().and_then(|columns| {
104+
columns
105+
.decks_cache
106+
.active_columns_mut(ctx.i18n, ctx.accounts)
107+
.unwrap()
108+
.selected = 0;
109+
104110
columns
105111
.decks_cache
106112
.selected_column_mut(ctx.i18n, ctx.accounts)
@@ -847,7 +853,13 @@ fn chrome_handle_app_action(
847853
if let Some(action) = m_action {
848854
let col = cols.selected_mut();
849855

850-
action.process(&mut col.router, &mut col.sheet_router);
856+
action.process(
857+
0,
858+
ctx,
859+
&mut columns.threads,
860+
&mut col.router,
861+
&mut col.sheet_router,
862+
);
851863
}
852864
}
853865
}
@@ -903,7 +915,13 @@ fn columns_route_to_profile(
903915
if let Some(action) = m_action {
904916
let col = cols.selected_mut();
905917

906-
action.process(&mut col.router, &mut col.sheet_router);
918+
action.process(
919+
0,
920+
ctx,
921+
&mut columns.threads,
922+
&mut col.router,
923+
&mut col.sheet_router,
924+
);
907925
}
908926
}
909927

crates/notedeck_columns/src/actionbar.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ pub enum NotesOpenResult {
3030
Thread(NewThreadNotes),
3131
}
3232

33+
impl NotesOpenResult {
34+
pub fn process(
35+
self,
36+
threads: &mut Threads,
37+
ndb: &Ndb,
38+
note_cache: &mut NoteCache,
39+
txn: &Transaction,
40+
timeline_cache: &mut TimelineCache,
41+
unknown_ids: &mut UnknownIds,
42+
) {
43+
match self {
44+
NotesOpenResult::Timeline(timeline_open_result) => {
45+
timeline_open_result.process(ndb, note_cache, txn, timeline_cache, unknown_ids);
46+
}
47+
NotesOpenResult::Thread(thread_open_result) => {
48+
thread_open_result.process(threads, ndb, txn, unknown_ids, note_cache);
49+
}
50+
}
51+
}
52+
}
53+
3354
pub enum TimelineOpenResult {
3455
NewNotes(NewNotes),
3556
}
@@ -63,6 +84,7 @@ fn execute_note_action(
6384
let can_post = accounts.get_selected_account().key.secret_key.is_some();
6485

6586
match action {
87+
NoteAction::MissingThreadSub => router_action = Some(RouterAction::MissingThreadSub),
6688
NoteAction::Scroll(ref scroll_info) => {
6789
tracing::trace!("timeline scroll {scroll_info:?}")
6890
}
@@ -81,6 +103,9 @@ fn execute_note_action(
81103
.open(ndb, note_cache, txn, pool, &kind)
82104
.map(NotesOpenResult::Timeline);
83105
}
106+
NoteAction::OpenColumn(args) => {
107+
router_action = Some(RouterAction::OpenColumn(args));
108+
}
84109
NoteAction::Note { note_id, preview } => 'ex: {
85110
let Ok(thread_selection) = ThreadSelection::from_note_id(ndb, note_cache, txn, note_id)
86111
else {
@@ -224,14 +249,7 @@ pub fn execute_and_process_note_action(
224249
);
225250

226251
if let Some(br) = resp.timeline_res {
227-
match br {
228-
NotesOpenResult::Timeline(timeline_open_result) => {
229-
timeline_open_result.process(ndb, note_cache, txn, timeline_cache, unknown_ids);
230-
}
231-
NotesOpenResult::Thread(thread_open_result) => {
232-
thread_open_result.process(threads, ndb, txn, unknown_ids, note_cache);
233-
}
234-
}
252+
br.process(threads, &ndb, note_cache, txn, timeline_cache, unknown_ids);
235253
}
236254

237255
resp.router_action

0 commit comments

Comments
 (0)