mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 08:21:47 +00:00
Bookmarks feed including UI
This commit is contained in:
parent
845ac978de
commit
8867cedc64
@ -130,6 +130,22 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) {
|
||||
ui.add_space(6.0);
|
||||
render_a_feed(app, ctx, ui, feed, false, &id, load_more);
|
||||
}
|
||||
FeedKind::Bookmarks => {
|
||||
let feed = GLOBALS.feed.get_feed_events();
|
||||
let id = "bookmarks";
|
||||
ui.add_space(10.0);
|
||||
ui.allocate_ui_with_layout(
|
||||
Vec2::new(ui.available_width(), ui.spacing().interact_size.y),
|
||||
egui::Layout::left_to_right(egui::Align::Center),
|
||||
|ui| {
|
||||
add_left_space(ui);
|
||||
ui.heading("Bookmarks");
|
||||
recompute_btn(ui);
|
||||
},
|
||||
);
|
||||
ui.add_space(6.0);
|
||||
render_a_feed(app, ctx, ui, feed, false, id, load_more);
|
||||
}
|
||||
FeedKind::Inbox(indirect) => {
|
||||
if read_setting!(public_key).is_none() {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
|
@ -1039,6 +1039,16 @@ impl GossipUi {
|
||||
Page::Feed(FeedKind::Inbox(self.inbox_include_indirect)),
|
||||
);
|
||||
}
|
||||
if self
|
||||
.add_selected_label(
|
||||
ui,
|
||||
self.page == Page::Feed(FeedKind::Bookmarks),
|
||||
"Bookmarks",
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
self.set_page(ctx, Page::Feed(FeedKind::Bookmarks));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,8 @@ use nostr_types::{Id, PublicKey};
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum FeedKind {
|
||||
List(PersonList, bool), // with replies
|
||||
Inbox(bool), // indirect
|
||||
Bookmarks,
|
||||
Inbox(bool), // indirect
|
||||
Thread {
|
||||
id: Id, // FIXME, should be an EventReference
|
||||
referenced_by: Id,
|
||||
@ -20,11 +21,11 @@ pub enum FeedKind {
|
||||
impl std::fmt::Display for FeedKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
FeedKind::DmChat(channel) => write!(f, "{}", channel.name()),
|
||||
FeedKind::List(pl, _) => match GLOBALS.storage.get_person_list_metadata(*pl) {
|
||||
Ok(Some(md)) => write!(f, "{}", md.title),
|
||||
_ => write!(f, "UNKNOWN"),
|
||||
},
|
||||
FeedKind::Bookmarks => write!(f, "Bookmarks"),
|
||||
FeedKind::Inbox(_) => write!(f, "Inbox"),
|
||||
FeedKind::Thread {
|
||||
id,
|
||||
@ -32,6 +33,7 @@ impl std::fmt::Display for FeedKind {
|
||||
author: _,
|
||||
} => write!(f, "Thread {}", crate::names::hex_id_short(&(*id).into())),
|
||||
FeedKind::Person(pk) => write!(f, "{}", crate::names::best_name_from_pubkey_lookup(pk)),
|
||||
FeedKind::DmChat(channel) => write!(f, "{}", channel.name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41,6 +43,7 @@ impl FeedKind {
|
||||
pub fn anchor_key(&self) -> String {
|
||||
match self {
|
||||
Self::List(personlist, _) => format!("list{}", personlist.as_u8()),
|
||||
Self::Bookmarks => "bookmarks".to_owned(),
|
||||
Self::Inbox(_) => "inbox".to_owned(),
|
||||
Self::Thread { .. } => "thread".to_owned(),
|
||||
Self::Person(pubkey) => format!("person{}", pubkey.as_hex_string()),
|
||||
@ -51,6 +54,7 @@ impl FeedKind {
|
||||
pub fn can_load_more(&self) -> bool {
|
||||
match self {
|
||||
Self::List(_, _) => true,
|
||||
Self::Bookmarks => false, // always full
|
||||
Self::Inbox(_) => true,
|
||||
Self::Thread { .. } => false, // always full
|
||||
Self::Person(_) => true,
|
||||
|
@ -295,6 +295,10 @@ impl Feed {
|
||||
|
||||
*self.current_feed_events.write() = events;
|
||||
}
|
||||
FeedKind::Bookmarks => {
|
||||
let ids = GLOBALS.bookmarks.read().get_bookmark_feed()?;
|
||||
*self.current_feed_events.write() = ids;
|
||||
}
|
||||
FeedKind::Inbox(indirect) => {
|
||||
if let Some(my_pubkey) = GLOBALS.identity.public_key() {
|
||||
// Ideally all replies would 'p' tag me (NIP-10)
|
||||
|
@ -1645,8 +1645,7 @@ impl Overlord {
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
FeedKind::DmChat(_) => (), // DmChat is complete, not chunked
|
||||
FeedKind::Thread { .. } => (), // Thread is complete, not chunked
|
||||
_ => (), // other feeds can't load more
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user