Show "replies to" in all feeds, make smaller

This commit is contained in:
Mike Dilger 2023-01-15 08:45:09 +13:00
parent 794f1927ad
commit ae1ecdd960

View File

@ -5,8 +5,8 @@ use crate::globals::{Globals, GLOBALS};
use crate::ui::widgets::{CopyButton, LikeButton, ReplyButton}; use crate::ui::widgets::{CopyButton, LikeButton, ReplyButton};
use eframe::egui; use eframe::egui;
use egui::{ use egui::{
Align, Color32, Context, Frame, Image, Layout, RichText, ScrollArea, SelectableLabel, Sense, Separator, Stroke, Align, Color32, Context, Frame, Image, Layout, RichText, ScrollArea, SelectableLabel, Sense,
TextEdit, Ui, Vec2, Separator, Stroke, TextEdit, TextStyle, Ui, Vec2,
}; };
use linkify::{LinkFinder, LinkKind}; use linkify::{LinkFinder, LinkKind};
use nostr_types::{Event, EventKind, Id, IdHex, PublicKeyHex, Tag}; use nostr_types::{Event, EventKind, Id, IdHex, PublicKeyHex, Tag};
@ -426,12 +426,11 @@ fn render_post_actual(
let feed_kind = GLOBALS.feed.get_feed_kind(); let feed_kind = GLOBALS.feed.get_feed_kind();
match feed_kind { match feed_kind {
FeedKind::Thread(id) => id == event.id, FeedKind::Thread(id) => id == event.id,
_ => false _ => false,
} }
}; };
Frame::none().fill(bgcolor).show(ui, |ui| { Frame::none().fill(bgcolor).show(ui, |ui| {
if is_main_event { if is_main_event {
thin_red_separator(ui); thin_red_separator(ui);
} }
@ -474,17 +473,17 @@ fn render_post_actual(
ui.horizontal(|ui| { ui.horizontal(|ui| {
GossipUi::render_person_name_line(ui, maybe_person.as_ref()); GossipUi::render_person_name_line(ui, maybe_person.as_ref());
if app.page == Page::FeedGeneral || app.page == Page::FeedPerson { if let Some((irt, _)) = event.replies_to() {
if let Some((irt, _)) = event.replies_to() { ui.add_space(8.0);
ui.add_space(8.0);
let idhex: IdHex = irt.into(); ui.style_mut().override_text_style = Some(TextStyle::Small);
let nam = format!("replies to #{}", GossipUi::hex_id_short(&idhex)); let idhex: IdHex = irt.into();
if ui.link(&nam).clicked() { let nam = format!("replies to #{}", GossipUi::hex_id_short(&idhex));
GLOBALS.feed.set_feed_to_thread(irt); if ui.link(&nam).clicked() {
app.page = Page::FeedThread; GLOBALS.feed.set_feed_to_thread(irt);
}; app.page = Page::FeedThread;
} };
ui.reset_style();
} }
ui.add_space(8.0); ui.add_space(8.0);
@ -495,7 +494,7 @@ fn render_post_actual(
ui.with_layout(Layout::right_to_left(Align::TOP), |ui| { ui.with_layout(Layout::right_to_left(Align::TOP), |ui| {
ui.menu_button(RichText::new("").size(28.0), |ui| { ui.menu_button(RichText::new("").size(28.0), |ui| {
if ! is_main_event && ui.button("View Thread").clicked() { if !is_main_event && ui.button("View Thread").clicked() {
GLOBALS.feed.set_feed_to_thread(event.id); GLOBALS.feed.set_feed_to_thread(event.id);
app.page = Page::FeedThread; app.page = Page::FeedThread;
} }
@ -512,8 +511,7 @@ fn render_post_actual(
} }
}); });
if ! is_main_event if !is_main_event && ui.button("").on_hover_text("View Thread").clicked()
&& ui.button("").on_hover_text("View Thread").clicked()
{ {
GLOBALS.feed.set_feed_to_thread(event.id); GLOBALS.feed.set_feed_to_thread(event.id);
app.page = Page::FeedThread; app.page = Page::FeedThread;