columns: navigate back when switching account

Fixes: https://github.com/damus-io/notedeck/issues/600
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-12-20 13:54:20 -08:00
parent 40c5dbf418
commit 475314da75
5 changed files with 45 additions and 15 deletions

View File

@@ -13,9 +13,24 @@ use uuid::Uuid;
// TODO: remove this
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct SwitchAccountAction {
/// Some index representing the source of the action
pub source: Option<usize>,
/// The account index to switch to
pub switch_to: usize,
}
impl SwitchAccountAction {
pub fn new(source: Option<usize>, switch_to: usize) -> Self {
SwitchAccountAction { source, switch_to }
}
}
#[derive(Debug)]
pub enum AccountsAction {
Switch(usize),
Switch(SwitchAccountAction),
Remove(usize),
}
@@ -338,8 +353,12 @@ impl Accounts {
self.accounts.len() - 1
};
let source: Option<usize> = None;
AddAccountAction {
accounts_action: Some(AccountsAction::Switch(switch_to_index)),
accounts_action: Some(AccountsAction::Switch(SwitchAccountAction::new(
source,
switch_to_index,
))),
unk_id_action: SingleUnkIdAction::pubkey(pubkey),
}
}

View File

@@ -20,7 +20,7 @@ pub mod ui;
mod unknowns;
mod user_account;
pub use accounts::{AccountData, Accounts, AccountsAction, AddAccountAction};
pub use accounts::{AccountData, Accounts, AccountsAction, AddAccountAction, SwitchAccountAction};
pub use app::App;
pub use args::Args;
pub use context::AppContext;