fix deck author bug & rename titles

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-10-08 19:10:04 -04:00
parent 0d994172a0
commit ee5aa32469
3 changed files with 26 additions and 19 deletions

View File

@@ -137,7 +137,7 @@ impl TimelineKind {
));
}
match Timeline::contact_list(&results[0].note) {
match Timeline::contact_list(&results[0].note, pk_src.clone()) {
Err(Error::Filter(FilterError::EmptyContactList)) => Some(Timeline::new(
TimelineKind::contact_list(pk_src),
FilterState::needs_remote(vec![contact_filter]),
@@ -156,22 +156,21 @@ impl TimelineKind {
match self {
TimelineKind::List(list_kind) => match list_kind {
ListKind::Contact(pubkey_source) => match pubkey_source {
PubkeySource::Explicit(pubkey) => format!(
"{}'s Home Timeline",
get_profile_displayname_string(ndb, pubkey)
),
PubkeySource::DeckAuthor => "Your Home Timeline".to_owned(),
PubkeySource::Explicit(pubkey) => {
format!("{}'s Contacts", get_profile_displayname_string(ndb, pubkey))
}
PubkeySource::DeckAuthor => "Contacts".to_owned(),
},
},
TimelineKind::Notifications(pubkey_source) => match pubkey_source {
PubkeySource::DeckAuthor => "Your Notifications".to_owned(),
PubkeySource::DeckAuthor => "Notifications".to_owned(),
PubkeySource::Explicit(pk) => format!(
"{}'s Notifications",
get_profile_displayname_string(ndb, pk)
),
},
TimelineKind::Profile(pubkey_source) => match pubkey_source {
PubkeySource::DeckAuthor => "Your Profile".to_owned(),
PubkeySource::DeckAuthor => "Profile".to_owned(),
PubkeySource::Explicit(pk) => {
format!("{}'s Profile", get_profile_displayname_string(ndb, pk))
}

View File

@@ -8,7 +8,6 @@ use std::fmt;
use std::sync::atomic::{AtomicU32, Ordering};
use egui_virtual_list::VirtualList;
use enostr::Pubkey;
use nostrdb::{Ndb, Note, Subscription, Transaction};
use std::cell::RefCell;
use std::hash::Hash;
@@ -180,9 +179,8 @@ pub struct Timeline {
impl Timeline {
/// Create a timeline from a contact list
pub fn contact_list(contact_list: &Note) -> Result<Self> {
pub fn contact_list(contact_list: &Note, pk_src: PubkeySource) -> Result<Self> {
let filter = filter::filter_from_tags(contact_list)?.into_follow_filter();
let pk_src = PubkeySource::Explicit(Pubkey::new(*contact_list.pubkey()));
Ok(Timeline::new(
TimelineKind::contact_list(pk_src),

View File

@@ -14,7 +14,7 @@ pub enum AddColumnResponse {
Timeline(Timeline),
}
#[derive(Clone)]
#[derive(Clone, Debug)]
enum AddColumnOption {
Universe,
Notification(PubkeySource),
@@ -22,17 +22,23 @@ enum AddColumnOption {
}
impl AddColumnOption {
pub fn take_as_response(self, ndb: &Ndb) -> Option<AddColumnResponse> {
pub fn take_as_response(
self,
ndb: &Ndb,
cur_account: Option<&UserAccount>,
) -> Option<AddColumnResponse> {
match self {
AddColumnOption::Universe => TimelineKind::Universe
.into_timeline(ndb, None)
.map(AddColumnResponse::Timeline),
AddColumnOption::Notification(pubkey) => TimelineKind::Notifications(pubkey)
.into_timeline(ndb, None)
.map(AddColumnResponse::Timeline),
AddColumnOption::Home(pubkey) => TimelineKind::contact_list(pubkey)
.into_timeline(ndb, None)
.into_timeline(ndb, cur_account.map(|a| a.pubkey.bytes()))
.map(AddColumnResponse::Timeline),
AddColumnOption::Home(pubkey) => {
let tlk = TimelineKind::contact_list(pubkey);
tlk.into_timeline(ndb, cur_account.map(|a| a.pubkey.bytes()))
.map(AddColumnResponse::Timeline)
}
}
}
}
@@ -52,7 +58,7 @@ impl<'a> AddColumnView<'a> {
for column_option_data in self.get_column_options() {
let option = column_option_data.option.clone();
if self.column_option_ui(ui, column_option_data).clicked() {
selected_option = option.take_as_response(self.ndb);
selected_option = option.take_as_response(self.ndb, self.cur_account);
}
ui.add(Separator::default().spacing(0.0));
@@ -172,7 +178,11 @@ impl<'a> AddColumnView<'a> {
});
if let Some(acc) = self.cur_account {
let source = PubkeySource::Explicit(acc.pubkey);
let source = if acc.secret_key.is_some() {
PubkeySource::DeckAuthor
} else {
PubkeySource::Explicit(acc.pubkey)
};
vec.push(ColumnOptionData {
title: "Home timeline",