fix(note-content): avoid empty text blocks
(cherry picked from commit baa7031c25d0f3d3e8952f49f6625252413559a3)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user