Clarify & enforce selected-only behavior in Accounts subscription

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-07-01 15:04:53 -04:00
parent f0158f71b2
commit a73596df48
7 changed files with 182 additions and 244 deletions

View File

@@ -136,7 +136,6 @@ pub fn process_accounts_view_response(
router.route_to(Route::add_account());
}
}
accounts.needs_relay_config();
action
}

View File

@@ -14,18 +14,15 @@ use crate::{
Result,
};
use notedeck::{
Accounts, AppAction, AppContext, DataPath, DataPathType, FilterState, UnknownIds,
FALLBACK_PUBKEY,
};
use notedeck::{Accounts, AppAction, AppContext, DataPath, DataPathType, FilterState, UnknownIds};
use notedeck_ui::{jobs::JobsCache, NoteOptions};
use enostr::{ClientMessage, Keypair, PoolRelay, Pubkey, RelayEvent, RelayMessage, RelayPool};
use enostr::{ClientMessage, PoolRelay, Pubkey, RelayEvent, RelayMessage, RelayPool};
use uuid::Uuid;
use egui_extras::{Size, StripBuilder};
use nostrdb::{Ndb, Transaction};
use nostrdb::Transaction;
use std::collections::{BTreeSet, HashMap};
use std::path::Path;
@@ -431,7 +428,6 @@ impl Damus {
for (pk, _) in &ctx.accounts.cache {
cache.add_deck_default(*pk);
}
set_demo(&mut cache, ctx.ndb, ctx.accounts, ctx.unknown_ids);
cache
};
@@ -697,7 +693,8 @@ fn timelines_view(
// StripBuilder rendering
let mut save_cols = false;
if let Some(action) = side_panel_action {
save_cols = save_cols || action.process(&mut app.timeline_cache, &mut app.decks_cache, ctx);
save_cols = save_cols
|| action.process(&mut app.timeline_cache, &mut app.decks_cache, ctx, ui.ctx());
}
let mut app_action: Option<AppAction> = None;
@@ -762,25 +759,6 @@ pub fn get_decks_mut<'a>(accounts: &Accounts, decks_cache: &'a mut DecksCache) -
decks_cache.decks_mut(accounts.selected_account_pubkey())
}
pub fn set_demo(
decks_cache: &mut DecksCache,
ndb: &Ndb,
accounts: &mut Accounts,
unk_ids: &mut UnknownIds,
) {
let fallback = decks_cache.get_fallback_pubkey();
let txn = Transaction::new(ndb).expect("txn");
if let Some(resp) = accounts.add_account(
ndb,
&txn,
Keypair::only_pubkey(*decks_cache.get_fallback_pubkey()),
) {
let txn = Transaction::new(ndb).expect("txn");
resp.unk_id_action.process_action(unk_ids, ndb, &txn);
}
accounts.select_account(fallback);
}
fn columns_to_decks_cache(cols: Columns, key: &[u8; 32]) -> DecksCache {
let mut account_to_decks: HashMap<Pubkey, Decks> = Default::default();
let decks = Decks::new(crate::decks::Deck::new_with_columns(

View File

@@ -74,11 +74,17 @@ impl SwitchingAction {
timeline_cache: &mut TimelineCache,
decks_cache: &mut DecksCache,
ctx: &mut AppContext<'_>,
ui_ctx: &egui::Context,
) -> bool {
match &self {
SwitchingAction::Accounts(account_action) => match account_action {
AccountsAction::Switch(switch_action) => {
ctx.accounts.select_account(&switch_action.switch_to);
ctx.accounts.select_account(
&switch_action.switch_to,
ctx.ndb,
ctx.pool,
ui_ctx,
);
// pop nav after switch
get_active_columns_mut(ctx.accounts, decks_cache)
.column_mut(switch_action.source_column)
@@ -374,7 +380,12 @@ fn process_render_nav_action(
}
RenderNavAction::SwitchingAction(switching_action) => {
if switching_action.process(&mut app.timeline_cache, &mut app.decks_cache, ctx) {
if switching_action.process(
&mut app.timeline_cache,
&mut app.decks_cache,
ctx,
ui.ctx(),
) {
return Some(ProcessNavResult::SwitchOccurred);
} else {
return None;