actionbar: move BarAction and add execute method
We will be executing baractions in multiple places, so factor this out. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
30
src/actionbar.rs
Normal file
30
src/actionbar.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use crate::{route::Route, Damus};
|
||||
use enostr::NoteId;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||
pub enum BarAction {
|
||||
Reply,
|
||||
OpenThread,
|
||||
}
|
||||
|
||||
impl BarAction {
|
||||
pub fn execute(self, app: &mut Damus, timeline: usize, replying_to: &[u8; 32]) {
|
||||
match self {
|
||||
BarAction::Reply => {
|
||||
let timeline = &mut app.timelines[timeline];
|
||||
timeline
|
||||
.routes
|
||||
.push(Route::Reply(NoteId::new(replying_to.to_owned())));
|
||||
timeline.navigating = true;
|
||||
}
|
||||
|
||||
BarAction::OpenThread => {
|
||||
let timeline = &mut app.timelines[timeline];
|
||||
timeline
|
||||
.routes
|
||||
.push(Route::Thread(NoteId::new(replying_to.to_owned())));
|
||||
timeline.navigating = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user