mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-24 03:24:21 +01:00
chrome: use actual columns noteaction executor
there is code duplication here and it is causing bugs
This commit is contained in:
@@ -6,13 +6,10 @@ use egui::{vec2, Button, Label, Layout, RichText, ThemePreference, Widget};
|
|||||||
use egui_extras::{Size, StripBuilder};
|
use egui_extras::{Size, StripBuilder};
|
||||||
use nostrdb::{ProfileRecord, Transaction};
|
use nostrdb::{ProfileRecord, Transaction};
|
||||||
use notedeck::{
|
use notedeck::{
|
||||||
profile::get_profile_url, App, AppAction, AppContext, NoteAction, NotedeckTextStyle,
|
profile::get_profile_url, App, AppAction, AppContext, NotedeckTextStyle, UserAccount,
|
||||||
UserAccount, WalletType,
|
WalletType,
|
||||||
};
|
|
||||||
use notedeck_columns::{
|
|
||||||
timeline::{ThreadSelection, TimelineKind},
|
|
||||||
Damus, Route,
|
|
||||||
};
|
};
|
||||||
|
use notedeck_columns::Damus;
|
||||||
use notedeck_dave::{Dave, DaveAvatar};
|
use notedeck_dave::{Dave, DaveAvatar};
|
||||||
use notedeck_ui::{AnimationHelper, ProfilePic};
|
use notedeck_ui::{AnimationHelper, ProfilePic};
|
||||||
|
|
||||||
@@ -468,54 +465,32 @@ fn chrome_handle_app_action(
|
|||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
) {
|
) {
|
||||||
match action {
|
match action {
|
||||||
AppAction::Note(note_action) => match note_action {
|
AppAction::Note(note_action) => {
|
||||||
NoteAction::Hashtag(hashtag) => {
|
chrome.switch_to_columns();
|
||||||
ChromePanelAction::columns_navigate(
|
let Some(columns) = chrome.get_columns() else {
|
||||||
ctx,
|
return;
|
||||||
chrome,
|
};
|
||||||
Route::Timeline(TimelineKind::Hashtag(hashtag)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
NoteAction::Reply(note_id) => {
|
let txn = Transaction::new(ctx.ndb).unwrap();
|
||||||
ChromePanelAction::columns_navigate(ctx, chrome, Route::Reply(note_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
NoteAction::Zap(_) => {
|
notedeck_columns::actionbar::execute_and_process_note_action(
|
||||||
todo!("implement note zaps in chrome");
|
¬e_action,
|
||||||
}
|
ctx.ndb,
|
||||||
|
columns
|
||||||
NoteAction::Context(context) => 'brk: {
|
.decks_cache
|
||||||
let txn = Transaction::new(ctx.ndb).unwrap();
|
.active_columns_mut(ctx.accounts)
|
||||||
let Some(note) = ctx.ndb.get_note_by_key(&txn, context.note_key).ok() else {
|
.unwrap(),
|
||||||
break 'brk;
|
0,
|
||||||
};
|
&mut columns.timeline_cache,
|
||||||
|
ctx.note_cache,
|
||||||
context.action.process(ui, ¬e, ctx.pool);
|
ctx.pool,
|
||||||
}
|
&txn,
|
||||||
|
ctx.unknown_ids,
|
||||||
NoteAction::Quote(note_id) => {
|
ctx.accounts,
|
||||||
ChromePanelAction::columns_navigate(ctx, chrome, Route::Quote(note_id));
|
ctx.global_wallet,
|
||||||
}
|
ctx.zaps,
|
||||||
|
ui,
|
||||||
NoteAction::Profile(pubkey) => {
|
);
|
||||||
ChromePanelAction::columns_navigate(
|
}
|
||||||
ctx,
|
|
||||||
chrome,
|
|
||||||
Route::Timeline(TimelineKind::Profile(pubkey)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
NoteAction::Note(note_id) => {
|
|
||||||
let txn = Transaction::new(ctx.ndb).unwrap();
|
|
||||||
let thread = ThreadSelection::from_note_id(ctx.ndb, ctx.note_cache, &txn, note_id);
|
|
||||||
|
|
||||||
match thread {
|
|
||||||
Ok(t) => ChromePanelAction::columns_navigate(ctx, chrome, Route::thread(t)),
|
|
||||||
|
|
||||||
Err(err) => tracing::error!("{:?}", err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,17 @@ impl Default for DecksCache {
|
|||||||
impl DecksCache {
|
impl DecksCache {
|
||||||
/// Gets the first column in the currently active user's active deck
|
/// Gets the first column in the currently active user's active deck
|
||||||
pub fn first_column_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Column> {
|
pub fn first_column_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Column> {
|
||||||
|
self.active_columns_mut(accounts)
|
||||||
|
.and_then(|ad| ad.columns_mut().first_mut())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the active columns
|
||||||
|
pub fn active_columns_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Columns> {
|
||||||
let account = accounts.get_selected_account()?;
|
let account = accounts.get_selected_account()?;
|
||||||
|
|
||||||
self.decks_mut(&account.key.pubkey)
|
self.decks_mut(&account.key.pubkey)
|
||||||
.active_deck_mut()
|
.active_deck_mut()
|
||||||
.and_then(|ad| ad.columns_mut().columns_mut().first_mut())
|
.map(|ad| ad.columns_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(mut account_to_decks: HashMap<Pubkey, Decks>) -> Self {
|
pub fn new(mut account_to_decks: HashMap<Pubkey, Decks>) -> Self {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ mod error;
|
|||||||
//mod note;
|
//mod note;
|
||||||
//mod block;
|
//mod block;
|
||||||
pub mod accounts;
|
pub mod accounts;
|
||||||
mod actionbar;
|
pub mod actionbar;
|
||||||
pub mod app_creation;
|
pub mod app_creation;
|
||||||
mod app_style;
|
mod app_style;
|
||||||
mod args;
|
mod args;
|
||||||
|
|||||||
Reference in New Issue
Block a user