mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-17 16:54:18 +01:00
ui: fix broken note previews
Also made the options more clear
Fixes: https://github.com/damus-io/notedeck/issues/959
Fixes: b6348b1507 ("note/options: simplify flag logic")
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -133,7 +133,7 @@ pub fn render_note_contents(
|
||||
let mut current_len: usize = 0;
|
||||
let truncate_len = 280;
|
||||
|
||||
if !options.has(NoteOptions::Preview) {
|
||||
if !options.has(NoteOptions::HasNotePreviews) {
|
||||
// need this for the rect to take the full width of the column
|
||||
let _ = ui.allocate_at_least(egui::vec2(ui.available_width(), 0.0), egui::Sense::click());
|
||||
}
|
||||
@@ -183,11 +183,11 @@ pub fn render_note_contents(
|
||||
}
|
||||
}
|
||||
|
||||
Mention::Note(note) if options.has(NoteOptions::Preview) => {
|
||||
Mention::Note(note) if options.has(NoteOptions::HasNotePreviews) => {
|
||||
inline_note = Some((note.id(), block.as_str()));
|
||||
}
|
||||
|
||||
Mention::Event(note) if options.has(NoteOptions::Preview) => {
|
||||
Mention::Event(note) if options.has(NoteOptions::HasNotePreviews) => {
|
||||
inline_note = Some((note.id(), block.as_str()));
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
jobs: &'a mut JobsCache,
|
||||
) -> Self {
|
||||
flags.set(NoteOptions::ActionBar, true);
|
||||
flags.set(NoteOptions::NotePreviews, true);
|
||||
flags.set(NoteOptions::HasNotePreviews, true);
|
||||
|
||||
let framed = false;
|
||||
let parent: Option<NoteKey> = None;
|
||||
@@ -154,7 +154,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
}
|
||||
|
||||
pub fn note_previews(mut self, enable: bool) -> Self {
|
||||
self.options_mut().set(NoteOptions::NotePreviews, enable);
|
||||
self.options_mut().set(NoteOptions::HasNotePreviews, enable);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
}
|
||||
|
||||
pub fn is_preview(mut self, is_preview: bool) -> Self {
|
||||
self.options_mut().set(NoteOptions::Preview, is_preview);
|
||||
self.options_mut().set(NoteOptions::IsPreview, is_preview);
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ bitflags! {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct NoteOptions: u64 {
|
||||
const ActionBar = 1 << 0;
|
||||
const NotePreviews = 1 << 1;
|
||||
const HasNotePreviews = 1 << 1;
|
||||
const SmallPfp = 1 << 2;
|
||||
const MediumPfp = 1 << 3;
|
||||
const Wide = 1 << 4;
|
||||
@@ -18,7 +18,7 @@ bitflags! {
|
||||
/// Scramble text so that its not distracting during development
|
||||
const ScrambleText = 1 << 9;
|
||||
/// Is this a note preview?
|
||||
const Preview = 1 << 10;
|
||||
const IsPreview = 1 << 10;
|
||||
/// Is the content truncated? If the length is over a certain size it
|
||||
/// will end with a ... and a "Show more" button.
|
||||
const Truncate = 1 << 11;
|
||||
@@ -28,7 +28,7 @@ bitflags! {
|
||||
impl Default for NoteOptions {
|
||||
fn default() -> NoteOptions {
|
||||
NoteOptions::OptionsButton
|
||||
| NoteOptions::NotePreviews
|
||||
| NoteOptions::HasNotePreviews
|
||||
| NoteOptions::ActionBar
|
||||
| NoteOptions::Truncate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user