@@ -372,19 +372,10 @@ impl Damus {
|
||||
pub fn new(ctx: &mut AppContext<'_>, args: &[String]) -> Self {
|
||||
// arg parsing
|
||||
|
||||
let (parsed_args, unrecognized_args) = ColumnsArgs::parse(
|
||||
args,
|
||||
ctx.accounts
|
||||
.get_selected_account()
|
||||
.as_ref()
|
||||
.map(|kp| &kp.pubkey),
|
||||
);
|
||||
let (parsed_args, unrecognized_args) =
|
||||
ColumnsArgs::parse(args, ctx.accounts.selected_account_pubkey());
|
||||
|
||||
let account = ctx
|
||||
.accounts
|
||||
.get_selected_account()
|
||||
.as_ref()
|
||||
.map(|a| a.pubkey.bytes());
|
||||
let account = ctx.accounts.selected_account_pubkey_bytes();
|
||||
|
||||
let mut timeline_cache = TimelineCache::default();
|
||||
let tmp_columns = !parsed_args.columns.is_empty();
|
||||
@@ -425,7 +416,7 @@ impl Damus {
|
||||
info!("DecksCache: creating new with demo configuration");
|
||||
let mut cache = DecksCache::new_with_demo_config(&mut timeline_cache, ctx);
|
||||
for account in ctx.accounts.get_accounts() {
|
||||
cache.add_deck_default(account.pubkey);
|
||||
cache.add_deck_default(account.key.pubkey);
|
||||
}
|
||||
set_demo(&mut cache, ctx.ndb, ctx.accounts, ctx.unknown_ids);
|
||||
|
||||
@@ -657,11 +648,9 @@ pub fn get_active_columns<'a>(accounts: &Accounts, decks_cache: &'a DecksCache)
|
||||
}
|
||||
|
||||
pub fn get_decks<'a>(accounts: &Accounts, decks_cache: &'a DecksCache) -> &'a Decks {
|
||||
let key = if let Some(acc) = accounts.get_selected_account() {
|
||||
&acc.pubkey
|
||||
} else {
|
||||
decks_cache.get_fallback_pubkey()
|
||||
};
|
||||
let key = accounts
|
||||
.selected_account_pubkey()
|
||||
.unwrap_or_else(|| decks_cache.get_fallback_pubkey());
|
||||
decks_cache.decks(key)
|
||||
}
|
||||
|
||||
@@ -675,10 +664,9 @@ pub fn get_active_columns_mut<'a>(
|
||||
}
|
||||
|
||||
pub fn get_decks_mut<'a>(accounts: &Accounts, decks_cache: &'a mut DecksCache) -> &'a mut Decks {
|
||||
if let Some(acc) = accounts.get_selected_account() {
|
||||
decks_cache.decks_mut(&acc.pubkey)
|
||||
} else {
|
||||
decks_cache.fallback_mut()
|
||||
match accounts.selected_account_pubkey() {
|
||||
Some(acc) => decks_cache.decks_mut(acc),
|
||||
None => decks_cache.fallback_mut(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ fn render_nav_body(
|
||||
}
|
||||
|
||||
Route::ComposeNote => {
|
||||
let kp = ctx.accounts.get_selected_account()?.to_full()?;
|
||||
let kp = ctx.accounts.get_selected_account()?.key.to_full()?;
|
||||
let draft = app.drafts.compose_mut();
|
||||
|
||||
let txn = Transaction::new(ctx.ndb).expect("txn");
|
||||
@@ -433,11 +433,9 @@ fn render_nav_body(
|
||||
let new_deck_state = app.view_state.id_to_deck_state.entry(id).or_default();
|
||||
let mut resp = None;
|
||||
if let Some(config_resp) = ConfigureDeckView::new(new_deck_state).ui(ui) {
|
||||
if let Some(cur_acc) = ctx.accounts.get_selected_account() {
|
||||
app.decks_cache.add_deck(
|
||||
cur_acc.pubkey,
|
||||
Deck::new(config_resp.icon, config_resp.name),
|
||||
);
|
||||
if let Some(cur_acc) = ctx.accounts.selected_account_pubkey() {
|
||||
app.decks_cache
|
||||
.add_deck(*cur_acc, Deck::new(config_resp.icon, config_resp.name));
|
||||
|
||||
// set new deck as active
|
||||
let cur_index = get_decks_mut(ctx.accounts, &mut app.decks_cache)
|
||||
@@ -462,11 +460,9 @@ fn render_nav_body(
|
||||
.decks_mut()
|
||||
.get_mut(*index)
|
||||
.expect("index wasn't valid");
|
||||
let id = ui.id().with((
|
||||
"edit-deck",
|
||||
ctx.accounts.get_selected_account().map(|k| k.pubkey),
|
||||
index,
|
||||
));
|
||||
let id = ui
|
||||
.id()
|
||||
.with(("edit-deck", ctx.accounts.selected_account_pubkey(), index));
|
||||
let deck_state = app
|
||||
.view_state
|
||||
.id_to_deck_state
|
||||
|
||||
@@ -69,7 +69,7 @@ impl<'a> AccountsView<'a> {
|
||||
|
||||
for i in 0..accounts.num_accounts() {
|
||||
let (account_pubkey, has_nsec) = match accounts.get_account(i) {
|
||||
Some(acc) => (acc.pubkey.bytes(), acc.secret_key.is_some()),
|
||||
Some(acc) => (acc.key.pubkey.bytes(), acc.key.secret_key.is_some()),
|
||||
None => continue,
|
||||
};
|
||||
|
||||
|
||||
@@ -143,18 +143,18 @@ impl AddColumnOption {
|
||||
AddColumnOption::Algo(algo_option) => AddColumnResponse::Algo(algo_option),
|
||||
AddColumnOption::Universe => AddColumnResponse::Timeline(TimelineKind::Universe),
|
||||
AddColumnOption::Notification(pubkey) => AddColumnResponse::Timeline(
|
||||
TimelineKind::Notifications(*pubkey.as_pubkey(&cur_account.pubkey)),
|
||||
TimelineKind::Notifications(*pubkey.as_pubkey(&cur_account.key.pubkey)),
|
||||
),
|
||||
AddColumnOption::UndecidedNotification => AddColumnResponse::UndecidedNotification,
|
||||
AddColumnOption::Contacts(pk_src) => AddColumnResponse::Timeline(
|
||||
TimelineKind::contact_list(*pk_src.as_pubkey(&cur_account.pubkey)),
|
||||
TimelineKind::contact_list(*pk_src.as_pubkey(&cur_account.key.pubkey)),
|
||||
),
|
||||
AddColumnOption::ExternalNotification => AddColumnResponse::ExternalNotification,
|
||||
AddColumnOption::UndecidedHashtag => AddColumnResponse::Hashtag,
|
||||
AddColumnOption::UndecidedIndividual => AddColumnResponse::UndecidedIndividual,
|
||||
AddColumnOption::ExternalIndividual => AddColumnResponse::ExternalIndividual,
|
||||
AddColumnOption::Individual(pubkey_source) => AddColumnResponse::Timeline(
|
||||
TimelineKind::profile(*pubkey_source.as_pubkey(&cur_account.pubkey)),
|
||||
TimelineKind::profile(*pubkey_source.as_pubkey(&cur_account.key.pubkey)),
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -453,10 +453,10 @@ impl<'a> AddColumnView<'a> {
|
||||
});
|
||||
|
||||
if let Some(acc) = self.cur_account {
|
||||
let source = if acc.secret_key.is_some() {
|
||||
let source = if acc.key.secret_key.is_some() {
|
||||
PubkeySource::DeckAuthor
|
||||
} else {
|
||||
PubkeySource::Explicit(acc.pubkey)
|
||||
PubkeySource::Explicit(acc.key.pubkey)
|
||||
};
|
||||
|
||||
vec.push(ColumnOptionData {
|
||||
@@ -498,10 +498,10 @@ impl<'a> AddColumnView<'a> {
|
||||
let mut vec = Vec::new();
|
||||
|
||||
if let Some(acc) = self.cur_account {
|
||||
let source = if acc.secret_key.is_some() {
|
||||
let source = if acc.key.secret_key.is_some() {
|
||||
PubkeySource::DeckAuthor
|
||||
} else {
|
||||
PubkeySource::Explicit(acc.pubkey)
|
||||
PubkeySource::Explicit(acc.key.pubkey)
|
||||
};
|
||||
|
||||
vec.push(ColumnOptionData {
|
||||
@@ -528,10 +528,10 @@ impl<'a> AddColumnView<'a> {
|
||||
let mut vec = Vec::new();
|
||||
|
||||
if let Some(acc) = self.cur_account {
|
||||
let source = if acc.secret_key.is_some() {
|
||||
let source = if acc.key.secret_key.is_some() {
|
||||
PubkeySource::DeckAuthor
|
||||
} else {
|
||||
PubkeySource::Explicit(acc.pubkey)
|
||||
PubkeySource::Explicit(acc.key.pubkey)
|
||||
};
|
||||
|
||||
vec.push(ColumnOptionData {
|
||||
@@ -606,7 +606,7 @@ pub fn render_add_column_routes(
|
||||
AddAlgoRoute::Base => add_column_view.algo_ui(ui),
|
||||
AddAlgoRoute::LastPerPubkey => {
|
||||
if let Some(deck_author) = ctx.accounts.get_selected_account() {
|
||||
add_column_view.algo_last_per_pk_ui(ui, deck_author.pubkey)
|
||||
add_column_view.algo_last_per_pk_ui(ui, deck_author.key.pubkey)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ pub fn get_account_url<'a>(
|
||||
account: Option<&UserAccount>,
|
||||
) -> &'a str {
|
||||
if let Some(selected_account) = account {
|
||||
if let Ok(profile) = ndb.get_profile_by_pubkey(txn, selected_account.pubkey.bytes()) {
|
||||
if let Ok(profile) = ndb.get_profile_by_pubkey(txn, selected_account.key.pubkey.bytes()) {
|
||||
get_profile_url_owned(Some(profile))
|
||||
} else {
|
||||
get_profile_url_owned(None)
|
||||
|
||||
@@ -111,7 +111,7 @@ impl<'a> DesktopSidePanel<'a> {
|
||||
ui.add_space(16.0);
|
||||
let is_interactive = self
|
||||
.selected_account
|
||||
.is_some_and(|s| s.secret_key.is_some());
|
||||
.is_some_and(|s| s.key.secret_key.is_some());
|
||||
let compose_resp = ui.add(compose_note_button(is_interactive, dark_mode));
|
||||
let compose_resp = if is_interactive {
|
||||
compose_resp
|
||||
@@ -599,7 +599,7 @@ fn show_decks<'a>(
|
||||
) -> InnerResponse<Option<usize>> {
|
||||
let show_decks_id = ui.id().with("show-decks");
|
||||
let account_id = if let Some(acc) = selected_account {
|
||||
acc.pubkey
|
||||
acc.key.pubkey
|
||||
} else {
|
||||
*decks_cache.get_fallback_pubkey()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user