commit d1a9e0020ec94d4126f6b331fa18801de1a8ee07
parent 1163dd8461eb0182d7b2e1a5e1940b451355b964
Author: Fernando LoĢpez Guevara <fernando.lguevara@gmail.com>
Date: Tue, 29 Jul 2025 21:34:28 -0300
fix(note-content): avoid empty text blocks
(cherry picked from commit baa7031c25d0f3d3e8952f49f6625252413559a3)
Diffstat:
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/crates/notedeck_ui/src/note/contents.rs b/crates/notedeck_ui/src/note/contents.rs
@@ -4,12 +4,12 @@ use crate::{
};
use notedeck::{JobsCache, RenderableMedia};
-use egui::{Color32, Hyperlink, RichText};
+use egui::{vec2, Color32, Hyperlink, RichText};
use nostrdb::{BlockType, Mention, Note, NoteKey, Transaction};
use tracing::warn;
use super::media::image_carousel;
-use notedeck::{update_imeta_blurhashes, IsFollowing, NoteCache, NoteContext};
+use notedeck::{update_imeta_blurhashes, IsFollowing, NoteCache, NoteContext, NotedeckTextStyle};
pub struct NoteContents<'a, 'd> {
note_context: &'a mut NoteContext<'d>,
@@ -158,9 +158,9 @@ pub fn render_note_contents<'a>(
return;
};
- ui.spacing_mut().item_spacing.x = 0.0;
+ ui.spacing_mut().item_spacing = vec2(0.0, 0.0);
- for block in blocks.iter(note) {
+ 'block_loop: for block in blocks.iter(note) {
match block.blocktype() {
BlockType::MentionBech32 => match block.as_mention().unwrap() {
Mention::Profile(profile) => {
@@ -258,17 +258,28 @@ pub fn render_note_contents<'a>(
current_len += block_str.len();
block_str
};
-
+ if block_str.trim().len() == 0 {
+ continue 'block_loop;
+ }
if options.contains(NoteOptions::ScrambleText) {
ui.add(
- egui::Label::new(rot13(block_str))
- .wrap()
- .selectable(selectable),
+ egui::Label::new(
+ RichText::new(rot13(block_str))
+ .text_style(NotedeckTextStyle::Body.text_style()),
+ )
+ .wrap()
+ .selectable(selectable),
);
} else {
- ui.add(egui::Label::new(block_str).wrap().selectable(selectable));
+ ui.add(
+ egui::Label::new(
+ RichText::new(block_str)
+ .text_style(NotedeckTextStyle::Body.text_style()),
+ )
+ .wrap()
+ .selectable(selectable),
+ );
}
-
// don't render any more blocks
if truncate {
break;