fix deck author bug & rename titles
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -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(
|
Err(Error::Filter(FilterError::EmptyContactList)) => Some(Timeline::new(
|
||||||
TimelineKind::contact_list(pk_src),
|
TimelineKind::contact_list(pk_src),
|
||||||
FilterState::needs_remote(vec![contact_filter]),
|
FilterState::needs_remote(vec![contact_filter]),
|
||||||
@@ -156,22 +156,21 @@ impl TimelineKind {
|
|||||||
match self {
|
match self {
|
||||||
TimelineKind::List(list_kind) => match list_kind {
|
TimelineKind::List(list_kind) => match list_kind {
|
||||||
ListKind::Contact(pubkey_source) => match pubkey_source {
|
ListKind::Contact(pubkey_source) => match pubkey_source {
|
||||||
PubkeySource::Explicit(pubkey) => format!(
|
PubkeySource::Explicit(pubkey) => {
|
||||||
"{}'s Home Timeline",
|
format!("{}'s Contacts", get_profile_displayname_string(ndb, pubkey))
|
||||||
get_profile_displayname_string(ndb, pubkey)
|
}
|
||||||
),
|
PubkeySource::DeckAuthor => "Contacts".to_owned(),
|
||||||
PubkeySource::DeckAuthor => "Your Home Timeline".to_owned(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TimelineKind::Notifications(pubkey_source) => match pubkey_source {
|
TimelineKind::Notifications(pubkey_source) => match pubkey_source {
|
||||||
PubkeySource::DeckAuthor => "Your Notifications".to_owned(),
|
PubkeySource::DeckAuthor => "Notifications".to_owned(),
|
||||||
PubkeySource::Explicit(pk) => format!(
|
PubkeySource::Explicit(pk) => format!(
|
||||||
"{}'s Notifications",
|
"{}'s Notifications",
|
||||||
get_profile_displayname_string(ndb, pk)
|
get_profile_displayname_string(ndb, pk)
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
TimelineKind::Profile(pubkey_source) => match pubkey_source {
|
TimelineKind::Profile(pubkey_source) => match pubkey_source {
|
||||||
PubkeySource::DeckAuthor => "Your Profile".to_owned(),
|
PubkeySource::DeckAuthor => "Profile".to_owned(),
|
||||||
PubkeySource::Explicit(pk) => {
|
PubkeySource::Explicit(pk) => {
|
||||||
format!("{}'s Profile", get_profile_displayname_string(ndb, pk))
|
format!("{}'s Profile", get_profile_displayname_string(ndb, pk))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use std::fmt;
|
|||||||
use std::sync::atomic::{AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicU32, Ordering};
|
||||||
|
|
||||||
use egui_virtual_list::VirtualList;
|
use egui_virtual_list::VirtualList;
|
||||||
use enostr::Pubkey;
|
|
||||||
use nostrdb::{Ndb, Note, Subscription, Transaction};
|
use nostrdb::{Ndb, Note, Subscription, Transaction};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
@@ -180,9 +179,8 @@ pub struct Timeline {
|
|||||||
|
|
||||||
impl Timeline {
|
impl Timeline {
|
||||||
/// Create a timeline from a contact list
|
/// 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 filter = filter::filter_from_tags(contact_list)?.into_follow_filter();
|
||||||
let pk_src = PubkeySource::Explicit(Pubkey::new(*contact_list.pubkey()));
|
|
||||||
|
|
||||||
Ok(Timeline::new(
|
Ok(Timeline::new(
|
||||||
TimelineKind::contact_list(pk_src),
|
TimelineKind::contact_list(pk_src),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub enum AddColumnResponse {
|
|||||||
Timeline(Timeline),
|
Timeline(Timeline),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
enum AddColumnOption {
|
enum AddColumnOption {
|
||||||
Universe,
|
Universe,
|
||||||
Notification(PubkeySource),
|
Notification(PubkeySource),
|
||||||
@@ -22,17 +22,23 @@ enum AddColumnOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
match self {
|
||||||
AddColumnOption::Universe => TimelineKind::Universe
|
AddColumnOption::Universe => TimelineKind::Universe
|
||||||
.into_timeline(ndb, None)
|
.into_timeline(ndb, None)
|
||||||
.map(AddColumnResponse::Timeline),
|
.map(AddColumnResponse::Timeline),
|
||||||
AddColumnOption::Notification(pubkey) => TimelineKind::Notifications(pubkey)
|
AddColumnOption::Notification(pubkey) => TimelineKind::Notifications(pubkey)
|
||||||
.into_timeline(ndb, None)
|
.into_timeline(ndb, cur_account.map(|a| a.pubkey.bytes()))
|
||||||
.map(AddColumnResponse::Timeline),
|
|
||||||
AddColumnOption::Home(pubkey) => TimelineKind::contact_list(pubkey)
|
|
||||||
.into_timeline(ndb, None)
|
|
||||||
.map(AddColumnResponse::Timeline),
|
.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() {
|
for column_option_data in self.get_column_options() {
|
||||||
let option = column_option_data.option.clone();
|
let option = column_option_data.option.clone();
|
||||||
if self.column_option_ui(ui, column_option_data).clicked() {
|
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));
|
ui.add(Separator::default().spacing(0.0));
|
||||||
@@ -172,7 +178,11 @@ impl<'a> AddColumnView<'a> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(acc) = self.cur_account {
|
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 {
|
vec.push(ColumnOptionData {
|
||||||
title: "Home timeline",
|
title: "Home timeline",
|
||||||
|
|||||||
Reference in New Issue
Block a user