make selected accounts non optional

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-06-25 22:09:55 -04:00
parent 9cacb6bb69
commit 8e92a97a57
16 changed files with 136 additions and 196 deletions

View File

@@ -5,10 +5,7 @@ use crate::app::NotedeckApp;
use egui::{vec2, Button, Label, Layout, Rect, RichText, ThemePreference, Widget};
use egui_extras::{Size, StripBuilder};
use nostrdb::{ProfileRecord, Transaction};
use notedeck::{
profile::get_profile_url, App, AppAction, AppContext, NotedeckTextStyle, UserAccount,
WalletType,
};
use notedeck::{App, AppAction, AppContext, NotedeckTextStyle, UserAccount, WalletType};
use notedeck_columns::{timeline::kind::ListKind, timeline::TimelineKind, Damus};
use notedeck_dave::{Dave, DaveAvatar};
@@ -95,27 +92,23 @@ impl ChromePanelAction {
ToolbarAction::Dave => chrome.switch_to_dave(),
ToolbarAction::Home => {
if let Some(pubkey) = ctx
.accounts
.get_selected_account()
.map(|acc| acc.key.pubkey)
{
Self::columns_switch(
ctx,
chrome,
&TimelineKind::List(ListKind::Contact(pubkey)),
);
}
Self::columns_switch(
ctx,
chrome,
&TimelineKind::List(ListKind::Contact(
ctx.accounts.get_selected_account().key.pubkey,
)),
);
}
ToolbarAction::Notifications => {
if let Some(pubkey) = ctx
.accounts
.get_selected_account()
.map(|acc| acc.key.pubkey)
{
Self::columns_switch(ctx, chrome, &TimelineKind::Notifications(pubkey));
}
Self::columns_switch(
ctx,
chrome,
&TimelineKind::Notifications(
ctx.accounts.get_selected_account().key.pubkey,
),
);
}
},
@@ -559,16 +552,12 @@ pub fn get_profile_url_owned(profile: Option<ProfileRecord<'_>>) -> &str {
pub fn get_account_url<'a>(
txn: &'a nostrdb::Transaction,
ndb: &nostrdb::Ndb,
account: Option<&UserAccount>,
account: &UserAccount,
) -> &'a str {
if let Some(selected_account) = account {
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)
}
if let Ok(profile) = ndb.get_profile_by_pubkey(txn, account.key.pubkey.bytes()) {
get_profile_url_owned(Some(profile))
} else {
get_profile_url(None)
get_profile_url_owned(None)
}
}