mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-19 01:24:21 +01:00
feat: add scramble flag for development text scrambling
This commit introduces a new scramble option to help reduce distractions
during development by scrambling text using rot13. When enabled via the
new `--scramble` flag, text displayed in various views is transformed,
making it easier to focus on layout and behavior without reading the
actual content.
App & Args Updates
- Added a `scramble: bool` field to the main application state (in `app.rs`).
- Extended argument parsing (in `args.rs`) to recognize the `--scramble` flag.
NoteOptions Enhancement
- Introduced a new bit flag `scramble_text` in `NoteOptions` with
corresponding setter/getter methods.
UI Adjustments
- Propagated the scramble flag through note rendering functions across
navigation, timeline, and note view modules.
- Updated several UI components (e.g., in `nav.rs`, `route.rs`, and
`contents.rs`) to accept and apply the new note options.
Rot13 Implementation
- Implemented a helper function (`rot13`) to scramble text
conditionally when the scramble option is enabled.
This feature is intended for development builds only, offering a way to
obscure text content during UI tweaks and testing.
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -52,6 +52,9 @@ pub struct Damus {
|
|||||||
pub since_optimize: bool,
|
pub since_optimize: bool,
|
||||||
pub textmode: bool,
|
pub textmode: bool,
|
||||||
|
|
||||||
|
/// Scramble text for development
|
||||||
|
pub scramble: bool,
|
||||||
|
|
||||||
pub unrecognized_args: BTreeSet<String>,
|
pub unrecognized_args: BTreeSet<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,6 +433,7 @@ impl Damus {
|
|||||||
drafts: Drafts::default(),
|
drafts: Drafts::default(),
|
||||||
state: DamusState::Initializing,
|
state: DamusState::Initializing,
|
||||||
textmode: parsed_args.textmode,
|
textmode: parsed_args.textmode,
|
||||||
|
scramble: parsed_args.scramble,
|
||||||
//frame_history: FrameHistory::default(),
|
//frame_history: FrameHistory::default(),
|
||||||
view_state: ViewState::default(),
|
view_state: ViewState::default(),
|
||||||
tmp_columns,
|
tmp_columns,
|
||||||
@@ -474,6 +478,7 @@ impl Damus {
|
|||||||
drafts: Drafts::default(),
|
drafts: Drafts::default(),
|
||||||
state: DamusState::Initializing,
|
state: DamusState::Initializing,
|
||||||
textmode: false,
|
textmode: false,
|
||||||
|
scramble: false,
|
||||||
tmp_columns: true,
|
tmp_columns: true,
|
||||||
//frame_history: FrameHistory::default(),
|
//frame_history: FrameHistory::default(),
|
||||||
view_state: ViewState::default(),
|
view_state: ViewState::default(),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ pub struct ColumnsArgs {
|
|||||||
pub columns: Vec<ArgColumn>,
|
pub columns: Vec<ArgColumn>,
|
||||||
pub since_optimize: bool,
|
pub since_optimize: bool,
|
||||||
pub textmode: bool,
|
pub textmode: bool,
|
||||||
|
pub scramble: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ColumnsArgs {
|
impl ColumnsArgs {
|
||||||
@@ -17,6 +18,7 @@ impl ColumnsArgs {
|
|||||||
columns: vec![],
|
columns: vec![],
|
||||||
since_optimize: true,
|
since_optimize: true,
|
||||||
textmode: false,
|
textmode: false,
|
||||||
|
scramble: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
@@ -28,6 +30,8 @@ impl ColumnsArgs {
|
|||||||
res.textmode = true;
|
res.textmode = true;
|
||||||
} else if arg == "--no-since-optimize" {
|
} else if arg == "--no-since-optimize" {
|
||||||
res.since_optimize = false;
|
res.since_optimize = false;
|
||||||
|
} else if arg == "--scramble" {
|
||||||
|
res.scramble = true;
|
||||||
} else if arg == "--filter" {
|
} else if arg == "--filter" {
|
||||||
i += 1;
|
i += 1;
|
||||||
let filter = if let Some(next_arg) = args.get(i) {
|
let filter = if let Some(next_arg) = args.get(i) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::{
|
|||||||
column::NavTitle,
|
column::NavTitle,
|
||||||
configure_deck::ConfigureDeckView,
|
configure_deck::ConfigureDeckView,
|
||||||
edit_deck::{EditDeckResponse, EditDeckView},
|
edit_deck::{EditDeckResponse, EditDeckView},
|
||||||
note::{PostAction, PostType},
|
note::{NoteOptions, PostAction, PostType},
|
||||||
profile::EditProfileView,
|
profile::EditProfileView,
|
||||||
support::SupportView,
|
support::SupportView,
|
||||||
RelayView, View,
|
RelayView, View,
|
||||||
@@ -243,6 +243,13 @@ fn render_nav_body(
|
|||||||
col: usize,
|
col: usize,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
) -> Option<RenderNavAction> {
|
) -> Option<RenderNavAction> {
|
||||||
|
let note_options = {
|
||||||
|
let mut options = NoteOptions::default();
|
||||||
|
options.set_textmode(app.textmode);
|
||||||
|
options.set_scramble_text(app.scramble);
|
||||||
|
options
|
||||||
|
};
|
||||||
|
|
||||||
match top {
|
match top {
|
||||||
Route::Timeline(kind) => render_timeline_route(
|
Route::Timeline(kind) => render_timeline_route(
|
||||||
ctx.ndb,
|
ctx.ndb,
|
||||||
@@ -253,7 +260,7 @@ fn render_nav_body(
|
|||||||
ctx.accounts,
|
ctx.accounts,
|
||||||
kind,
|
kind,
|
||||||
col,
|
col,
|
||||||
app.textmode,
|
note_options,
|
||||||
depth,
|
depth,
|
||||||
ui,
|
ui,
|
||||||
),
|
),
|
||||||
@@ -310,6 +317,7 @@ fn render_nav_body(
|
|||||||
ctx.img_cache,
|
ctx.img_cache,
|
||||||
¬e,
|
¬e,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
)
|
)
|
||||||
.id_source(id)
|
.id_source(id)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
@@ -345,6 +353,7 @@ fn render_nav_body(
|
|||||||
draft,
|
draft,
|
||||||
¬e,
|
¬e,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
)
|
)
|
||||||
.id_source(id)
|
.id_source(id)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
@@ -366,6 +375,7 @@ fn render_nav_body(
|
|||||||
ctx.note_cache,
|
ctx.note_cache,
|
||||||
kp,
|
kp,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
)
|
)
|
||||||
.ui(&txn, ui);
|
.ui(&txn, ui);
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,13 @@ pub fn render_timeline_route(
|
|||||||
accounts: &mut Accounts,
|
accounts: &mut Accounts,
|
||||||
kind: &TimelineKind,
|
kind: &TimelineKind,
|
||||||
col: usize,
|
col: usize,
|
||||||
textmode: bool,
|
mut note_options: NoteOptions,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
) -> Option<RenderNavAction> {
|
) -> Option<RenderNavAction> {
|
||||||
let note_options = {
|
if kind == &TimelineKind::Universe {
|
||||||
let mut options = NoteOptions::new(kind == &TimelineKind::Universe);
|
note_options.set_hide_media(true);
|
||||||
options.set_textmode(textmode);
|
}
|
||||||
options
|
|
||||||
};
|
|
||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
TimelineKind::List(_)
|
TimelineKind::List(_)
|
||||||
@@ -63,6 +61,7 @@ pub fn render_timeline_route(
|
|||||||
col,
|
col,
|
||||||
ui,
|
ui,
|
||||||
&accounts.mutefun(),
|
&accounts.mutefun(),
|
||||||
|
note_options,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// we render profiles like timelines if they are at the root
|
// we render profiles like timelines if they are at the root
|
||||||
@@ -88,7 +87,7 @@ pub fn render_timeline_route(
|
|||||||
unknown_ids,
|
unknown_ids,
|
||||||
img_cache,
|
img_cache,
|
||||||
id.selected_or_root(),
|
id.selected_or_root(),
|
||||||
textmode,
|
note_options,
|
||||||
&accounts.mutefun(),
|
&accounts.mutefun(),
|
||||||
)
|
)
|
||||||
.id_source(egui::Id::new(("threadscroll", col)))
|
.id_source(egui::Id::new(("threadscroll", col)))
|
||||||
@@ -109,6 +108,7 @@ pub fn render_profile_route(
|
|||||||
col: usize,
|
col: usize,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
is_muted: &MuteFun,
|
is_muted: &MuteFun,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Option<RenderNavAction> {
|
) -> Option<RenderNavAction> {
|
||||||
let action = ProfileView::new(
|
let action = ProfileView::new(
|
||||||
pubkey,
|
pubkey,
|
||||||
@@ -120,7 +120,7 @@ pub fn render_profile_route(
|
|||||||
img_cache,
|
img_cache,
|
||||||
unknown_ids,
|
unknown_ids,
|
||||||
is_muted,
|
is_muted,
|
||||||
NoteOptions::default(),
|
note_options,
|
||||||
)
|
)
|
||||||
.ui(ui);
|
.ui(ui);
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ impl egui::Widget for &mut NoteContents<'_> {
|
|||||||
|
|
||||||
/// Render an inline note preview with a border. These are used when
|
/// Render an inline note preview with a border. These are used when
|
||||||
/// notes are references within a note
|
/// notes are references within a note
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn render_note_preview(
|
pub fn render_note_preview(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
@@ -75,6 +76,7 @@ pub fn render_note_preview(
|
|||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
id: &[u8; 32],
|
id: &[u8; 32],
|
||||||
parent: NoteKey,
|
parent: NoteKey,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> NoteResponse {
|
) -> NoteResponse {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_function!();
|
puffin::profile_function!();
|
||||||
@@ -112,7 +114,7 @@ pub fn render_note_preview(
|
|||||||
ui.visuals().noninteractive().bg_stroke.color,
|
ui.visuals().noninteractive().bg_stroke.color,
|
||||||
))
|
))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui::NoteView::new(ndb, note_cache, img_cache, ¬e)
|
ui::NoteView::new(ndb, note_cache, img_cache, ¬e, note_options)
|
||||||
.actionbar(false)
|
.actionbar(false)
|
||||||
.small_pfp(true)
|
.small_pfp(true)
|
||||||
.wide(true)
|
.wide(true)
|
||||||
@@ -225,7 +227,11 @@ fn render_note_contents(
|
|||||||
BlockType::Text => {
|
BlockType::Text => {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_scope!("text contents");
|
puffin::profile_scope!("text contents");
|
||||||
ui.add(egui::Label::new(block.as_str()).selectable(selectable));
|
if options.has_scramble_text() {
|
||||||
|
ui.add(egui::Label::new(rot13(block.as_str())).selectable(selectable));
|
||||||
|
} else {
|
||||||
|
ui.add(egui::Label::new(block.as_str()).selectable(selectable));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
@@ -236,7 +242,7 @@ fn render_note_contents(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let preview_note_action = if let Some((id, _block_str)) = inline_note {
|
let preview_note_action = if let Some((id, _block_str)) = inline_note {
|
||||||
render_note_preview(ui, ndb, note_cache, img_cache, txn, id, note_key).action
|
render_note_preview(ui, ndb, note_cache, img_cache, txn, id, note_key, options).action
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@@ -253,6 +259,24 @@ fn render_note_contents(
|
|||||||
NoteResponse::new(response.response).with_action(note_action)
|
NoteResponse::new(response.response).with_action(note_action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn rot13(input: &str) -> String {
|
||||||
|
input
|
||||||
|
.chars()
|
||||||
|
.map(|c| {
|
||||||
|
if c.is_ascii_lowercase() {
|
||||||
|
// Rotate lowercase letters
|
||||||
|
(((c as u8 - b'a' + 13) % 26) + b'a') as char
|
||||||
|
} else if c.is_ascii_uppercase() {
|
||||||
|
// Rotate uppercase letters
|
||||||
|
(((c as u8 - b'A' + 13) % 26) + b'A') as char
|
||||||
|
} else {
|
||||||
|
// Leave other characters unchanged
|
||||||
|
c
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
fn image_carousel(
|
fn image_carousel(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
img_cache: &mut ImageCache,
|
img_cache: &mut ImageCache,
|
||||||
|
|||||||
@@ -76,8 +76,11 @@ impl<'a> NoteView<'a> {
|
|||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut ImageCache,
|
img_cache: &'a mut ImageCache,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
|
mut flags: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let flags = NoteOptions::actionbar | NoteOptions::note_previews;
|
flags.set_actionbar(true);
|
||||||
|
flags.set_note_previews(true);
|
||||||
|
|
||||||
let parent: Option<NoteKey> = None;
|
let parent: Option<NoteKey> = None;
|
||||||
Self {
|
Self {
|
||||||
ndb,
|
ndb,
|
||||||
@@ -89,11 +92,6 @@ impl<'a> NoteView<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn note_options(mut self, options: NoteOptions) -> Self {
|
|
||||||
*self.options_mut() = options;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn textmode(mut self, enable: bool) -> Self {
|
pub fn textmode(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set_textmode(enable);
|
self.options_mut().set_textmode(enable);
|
||||||
self
|
self
|
||||||
@@ -287,7 +285,14 @@ impl<'a> NoteView<'a> {
|
|||||||
.text_style(style.text_style()),
|
.text_style(style.text_style()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
NoteView::new(self.ndb, self.note_cache, self.img_cache, ¬e_to_repost).show(ui)
|
NoteView::new(
|
||||||
|
self.ndb,
|
||||||
|
self.note_cache,
|
||||||
|
self.img_cache,
|
||||||
|
¬e_to_repost,
|
||||||
|
self.flags,
|
||||||
|
)
|
||||||
|
.show(ui)
|
||||||
} else {
|
} else {
|
||||||
self.show_standard(ui)
|
self.show_standard(ui)
|
||||||
}
|
}
|
||||||
@@ -393,6 +398,7 @@ impl<'a> NoteView<'a> {
|
|||||||
self.ndb,
|
self.ndb,
|
||||||
self.img_cache,
|
self.img_cache,
|
||||||
self.note_cache,
|
self.note_cache,
|
||||||
|
self.flags,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.inner;
|
.inner;
|
||||||
@@ -464,6 +470,7 @@ impl<'a> NoteView<'a> {
|
|||||||
self.ndb,
|
self.ndb,
|
||||||
self.img_cache,
|
self.img_cache,
|
||||||
self.note_cache,
|
self.note_cache,
|
||||||
|
self.flags,
|
||||||
);
|
);
|
||||||
|
|
||||||
if action.is_some() {
|
if action.is_some() {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ bitflags! {
|
|||||||
const textmode = 0b0000000001000000;
|
const textmode = 0b0000000001000000;
|
||||||
const options_button = 0b0000000010000000;
|
const options_button = 0b0000000010000000;
|
||||||
const hide_media = 0b0000000100000000;
|
const hide_media = 0b0000000100000000;
|
||||||
|
|
||||||
|
/// Scramble text so that its not distracting during development
|
||||||
|
const scramble_text = 0b0000001000000000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +55,7 @@ impl NoteOptions {
|
|||||||
create_bit_methods!(set_wide, has_wide, wide);
|
create_bit_methods!(set_wide, has_wide, wide);
|
||||||
create_bit_methods!(set_options_button, has_options_button, options_button);
|
create_bit_methods!(set_options_button, has_options_button, options_button);
|
||||||
create_bit_methods!(set_hide_media, has_hide_media, hide_media);
|
create_bit_methods!(set_hide_media, has_hide_media, hide_media);
|
||||||
|
create_bit_methods!(set_scramble_text, has_scramble_text, scramble_text);
|
||||||
|
|
||||||
pub fn new(is_universe_timeline: bool) -> Self {
|
pub fn new(is_universe_timeline: bool) -> Self {
|
||||||
let mut options = NoteOptions::default();
|
let mut options = NoteOptions::default();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::media_upload::{nostrbuild_nip96_upload, MediaPath};
|
|||||||
use crate::post::{downcast_post_buffer, MentionType, NewPost};
|
use crate::post::{downcast_post_buffer, MentionType, NewPost};
|
||||||
use crate::profile::get_display_name;
|
use crate::profile::get_display_name;
|
||||||
use crate::ui::search_results::SearchResultsView;
|
use crate::ui::search_results::SearchResultsView;
|
||||||
use crate::ui::{self, Preview, PreviewConfig};
|
use crate::ui::{self, note::NoteOptions, Preview, PreviewConfig};
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
use egui::text::{CCursorRange, LayoutJob};
|
use egui::text::{CCursorRange, LayoutJob};
|
||||||
use egui::text_edit::TextEditOutput;
|
use egui::text_edit::TextEditOutput;
|
||||||
@@ -27,6 +27,7 @@ pub struct PostView<'a> {
|
|||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -82,6 +83,7 @@ pub struct PostResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PostView<'a> {
|
impl<'a> PostView<'a> {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
@@ -90,6 +92,7 @@ impl<'a> PostView<'a> {
|
|||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source: Option<egui::Id> = None;
|
let id_source: Option<egui::Id> = None;
|
||||||
PostView {
|
PostView {
|
||||||
@@ -101,6 +104,7 @@ impl<'a> PostView<'a> {
|
|||||||
id_source,
|
id_source,
|
||||||
post_type,
|
post_type,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +306,7 @@ impl<'a> PostView<'a> {
|
|||||||
txn,
|
txn,
|
||||||
id.bytes(),
|
id.bytes(),
|
||||||
nostrdb::NoteKey::new(0),
|
nostrdb::NoteKey::new(0),
|
||||||
|
self.note_options,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -686,6 +691,7 @@ mod preview {
|
|||||||
app.note_cache,
|
app.note_cache,
|
||||||
self.poster.to_filled(),
|
self.poster.to_filled(),
|
||||||
ui.available_rect_before_wrap(),
|
ui.available_rect_before_wrap(),
|
||||||
|
NoteOptions::default(),
|
||||||
)
|
)
|
||||||
.ui(&txn, ui);
|
.ui(&txn, ui);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ use enostr::{FilledKeypair, NoteId};
|
|||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
use notedeck::{ImageCache, NoteCache};
|
use notedeck::{ImageCache, NoteCache};
|
||||||
|
|
||||||
use crate::{draft::Draft, ui};
|
use crate::{
|
||||||
|
draft::Draft,
|
||||||
|
ui::{self, note::NoteOptions},
|
||||||
|
};
|
||||||
|
|
||||||
use super::{PostResponse, PostType};
|
use super::{PostResponse, PostType};
|
||||||
|
|
||||||
@@ -15,9 +18,11 @@ pub struct QuoteRepostView<'a> {
|
|||||||
quoting_note: &'a nostrdb::Note<'a>,
|
quoting_note: &'a nostrdb::Note<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> QuoteRepostView<'a> {
|
impl<'a> QuoteRepostView<'a> {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
@@ -26,6 +31,7 @@ impl<'a> QuoteRepostView<'a> {
|
|||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
quoting_note: &'a nostrdb::Note<'a>,
|
quoting_note: &'a nostrdb::Note<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source: Option<egui::Id> = None;
|
let id_source: Option<egui::Id> = None;
|
||||||
QuoteRepostView {
|
QuoteRepostView {
|
||||||
@@ -37,6 +43,7 @@ impl<'a> QuoteRepostView<'a> {
|
|||||||
quoting_note,
|
quoting_note,
|
||||||
id_source,
|
id_source,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +59,7 @@ impl<'a> QuoteRepostView<'a> {
|
|||||||
self.note_cache,
|
self.note_cache,
|
||||||
self.poster,
|
self.poster,
|
||||||
self.inner_rect,
|
self.inner_rect,
|
||||||
|
self.note_options,
|
||||||
)
|
)
|
||||||
.id_source(id)
|
.id_source(id)
|
||||||
.ui(self.quoting_note.txn().unwrap(), ui)
|
.ui(self.quoting_note.txn().unwrap(), ui)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::draft::Draft;
|
use crate::draft::Draft;
|
||||||
use crate::ui;
|
use crate::ui;
|
||||||
use crate::ui::note::{PostResponse, PostType};
|
use crate::ui::note::{NoteOptions, PostResponse, PostType};
|
||||||
use enostr::{FilledKeypair, NoteId};
|
use enostr::{FilledKeypair, NoteId};
|
||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
|
|
||||||
@@ -15,9 +15,11 @@ pub struct PostReplyView<'a> {
|
|||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PostReplyView<'a> {
|
impl<'a> PostReplyView<'a> {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
@@ -26,6 +28,7 @@ impl<'a> PostReplyView<'a> {
|
|||||||
img_cache: &'a mut ImageCache,
|
img_cache: &'a mut ImageCache,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source: Option<egui::Id> = None;
|
let id_source: Option<egui::Id> = None;
|
||||||
PostReplyView {
|
PostReplyView {
|
||||||
@@ -37,6 +40,7 @@ impl<'a> PostReplyView<'a> {
|
|||||||
img_cache,
|
img_cache,
|
||||||
id_source,
|
id_source,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,11 +71,17 @@ impl<'a> PostReplyView<'a> {
|
|||||||
egui::Frame::none()
|
egui::Frame::none()
|
||||||
.outer_margin(egui::Margin::same(note_offset))
|
.outer_margin(egui::Margin::same(note_offset))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui::NoteView::new(self.ndb, self.note_cache, self.img_cache, self.note)
|
ui::NoteView::new(
|
||||||
.actionbar(false)
|
self.ndb,
|
||||||
.medium_pfp(true)
|
self.note_cache,
|
||||||
.options_button(true)
|
self.img_cache,
|
||||||
.show(ui);
|
self.note,
|
||||||
|
self.note_options,
|
||||||
|
)
|
||||||
|
.actionbar(false)
|
||||||
|
.medium_pfp(true)
|
||||||
|
.options_button(true)
|
||||||
|
.show(ui);
|
||||||
});
|
});
|
||||||
|
|
||||||
let id = self.id();
|
let id = self.id();
|
||||||
@@ -87,6 +97,7 @@ impl<'a> PostReplyView<'a> {
|
|||||||
self.note_cache,
|
self.note_cache,
|
||||||
self.poster,
|
self.poster,
|
||||||
self.inner_rect,
|
self.inner_rect,
|
||||||
|
self.note_options,
|
||||||
)
|
)
|
||||||
.id_source(id)
|
.id_source(id)
|
||||||
.ui(self.note.txn().unwrap(), ui)
|
.ui(self.note.txn().unwrap(), ui)
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
use crate::{actionbar::NoteAction, ui};
|
use crate::{
|
||||||
|
actionbar::NoteAction,
|
||||||
|
ui::{self, note::NoteOptions},
|
||||||
|
};
|
||||||
use egui::{Label, RichText, Sense};
|
use egui::{Label, RichText, Sense};
|
||||||
use nostrdb::{Ndb, Note, NoteReply, Transaction};
|
use nostrdb::{Ndb, Note, NoteReply, Transaction};
|
||||||
use notedeck::{ImageCache, NoteCache};
|
use notedeck::{ImageCache, NoteCache};
|
||||||
@@ -11,6 +14,7 @@ pub fn reply_desc(
|
|||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
img_cache: &mut ImageCache,
|
img_cache: &mut ImageCache,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Option<NoteAction> {
|
) -> Option<NoteAction> {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_function!();
|
puffin::profile_function!();
|
||||||
@@ -41,7 +45,7 @@ pub fn reply_desc(
|
|||||||
if r.hovered() {
|
if r.hovered() {
|
||||||
r.on_hover_ui_at_pointer(|ui| {
|
r.on_hover_ui_at_pointer(|ui| {
|
||||||
ui.set_max_width(400.0);
|
ui.set_max_width(400.0);
|
||||||
ui::NoteView::new(ndb, note_cache, img_cache, note)
|
ui::NoteView::new(ndb, note_cache, img_cache, note, note_options)
|
||||||
.actionbar(false)
|
.actionbar(false)
|
||||||
.wide(true)
|
.wide(true)
|
||||||
.show(ui);
|
.show(ui);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ pub struct ThreadView<'a> {
|
|||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
img_cache: &'a mut ImageCache,
|
img_cache: &'a mut ImageCache,
|
||||||
selected_note_id: &'a [u8; 32],
|
selected_note_id: &'a [u8; 32],
|
||||||
textmode: bool,
|
note_options: NoteOptions,
|
||||||
id_source: egui::Id,
|
id_source: egui::Id,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ impl<'a> ThreadView<'a> {
|
|||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
img_cache: &'a mut ImageCache,
|
img_cache: &'a mut ImageCache,
|
||||||
selected_note_id: &'a [u8; 32],
|
selected_note_id: &'a [u8; 32],
|
||||||
textmode: bool,
|
note_options: NoteOptions,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source = egui::Id::new("threadscroll_threadview");
|
let id_source = egui::Id::new("threadscroll_threadview");
|
||||||
@@ -42,7 +42,7 @@ impl<'a> ThreadView<'a> {
|
|||||||
unknown_ids,
|
unknown_ids,
|
||||||
img_cache,
|
img_cache,
|
||||||
selected_note_id,
|
selected_note_id,
|
||||||
textmode,
|
note_options,
|
||||||
id_source,
|
id_source,
|
||||||
is_muted,
|
is_muted,
|
||||||
}
|
}
|
||||||
@@ -101,15 +101,10 @@ impl<'a> ThreadView<'a> {
|
|||||||
error!("error polling notes into thread timeline: {err}");
|
error!("error polling notes into thread timeline: {err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is threadview. We are not the universe view...
|
|
||||||
let is_universe = false;
|
|
||||||
let mut note_options = NoteOptions::new(is_universe);
|
|
||||||
note_options.set_textmode(self.textmode);
|
|
||||||
|
|
||||||
TimelineTabView::new(
|
TimelineTabView::new(
|
||||||
thread_timeline.current_view(),
|
thread_timeline.current_view(),
|
||||||
true,
|
true,
|
||||||
note_options,
|
self.note_options,
|
||||||
&txn,
|
&txn,
|
||||||
self.ndb,
|
self.ndb,
|
||||||
self.note_cache,
|
self.note_cache,
|
||||||
|
|||||||
@@ -388,10 +388,14 @@ impl<'a> TimelineTabView<'a> {
|
|||||||
|
|
||||||
if !muted {
|
if !muted {
|
||||||
ui::padding(8.0, ui, |ui| {
|
ui::padding(8.0, ui, |ui| {
|
||||||
let resp =
|
let resp = ui::NoteView::new(
|
||||||
ui::NoteView::new(self.ndb, self.note_cache, self.img_cache, ¬e)
|
self.ndb,
|
||||||
.note_options(self.note_options)
|
self.note_cache,
|
||||||
.show(ui);
|
self.img_cache,
|
||||||
|
¬e,
|
||||||
|
self.note_options,
|
||||||
|
)
|
||||||
|
.show(ui);
|
||||||
|
|
||||||
if let Some(note_action) = resp.action {
|
if let Some(note_action) = resp.action {
|
||||||
action = Some(note_action)
|
action = Some(note_action)
|
||||||
|
|||||||
Reference in New Issue
Block a user