notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 8e32f757f0d36758fd5919ea2f2367aa1287fd96
parent b1339c8a248de94bd27cbbba47867f9569802c61
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 17 Sep 2024 15:37:14 -0700

Merge 'Repost improvements #314'

This slightly improves the style of reposts. Icon color and size still
needs an update[2]

We also update nostrdb[1] to support instant kind6 ingestion, making
reposts render immediately

William Casarin (3):
      repost: update style
      nostrdb: update to support fast kind6 repost ingest

[1] https://github.com/damus-io/nostrdb/commit/cd9ba0ea7dfd021f2a3e98aefef87990d161aab3
[2] https://github.com/user-attachments/assets/23feba47-9d63-443f-9968-eba93053fc24

Diffstat:
MCargo.lock | 2+-
MCargo.toml | 2+-
Menostr/Cargo.toml | 2+-
Mqueries/reposts.json | 8+-------
Msrc/app_style.rs | 2+-
Msrc/ui/note/mod.rs | 13++++++++-----
Msrc/ui/profile/preview.rs | 18+++++++++++++-----
7 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -2477,7 +2477,7 @@ dependencies = [ [[package]] name = "nostrdb" version = "0.3.4" -source = "git+https://github.com/damus-io/nostrdb-rs?rev=6d22af6d5159be4c9e4579f8c9d3af836e0d470a#6d22af6d5159be4c9e4579f8c9d3af836e0d470a" +source = "git+https://github.com/damus-io/nostrdb-rs?rev=9bbafd8a2e904b77a51e7cfca71eb5bb5650e829#9bbafd8a2e904b77a51e7cfca71eb5bb5650e829" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml @@ -28,7 +28,7 @@ serde_derive = "1" serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence tracing = "0.1.40" #wasm-bindgen = "0.2.83" -nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "6d22af6d5159be4c9e4579f8c9d3af836e0d470a" } +nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "9bbafd8a2e904b77a51e7cfca71eb5bb5650e829" } #nostrdb = { path = "/Users/jb55/dev/github/damus-io/nostrdb-rs" } #nostrdb = "0.3.4" enostr = { path = "enostr" } diff --git a/enostr/Cargo.toml b/enostr/Cargo.toml @@ -11,7 +11,7 @@ serde_derive = "1" serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence serde_json = "1.0.89" nostr = { version = "0.30.0" } -nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "6d22af6d5159be4c9e4579f8c9d3af836e0d470a" } +nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "9bbafd8a2e904b77a51e7cfca71eb5bb5650e829" } hex = "0.4.3" tracing = "0.1.40" env_logger = "0.11.1" diff --git a/queries/reposts.json b/queries/reposts.json @@ -1,7 +1 @@ -{ - "limit": 100, - "kinds": [ - 1, 6 - ], - "#p": ["32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"] -} +{ "limit": 100, "kinds": [ 6 ] } diff --git a/src/app_style.rs b/src/app_style.rs @@ -96,7 +96,7 @@ pub fn mobile_font_size(text_style: &NotedeckTextStyle) -> f32 { } } -#[derive(EnumIter)] +#[derive(Copy, Clone, Eq, PartialEq, Debug, EnumIter)] pub enum NotedeckTextStyle { Heading, Heading2, diff --git a/src/ui/note/mod.rs b/src/ui/note/mod.rs @@ -327,19 +327,21 @@ impl<'a> NoteView<'a> { action: None, } } else { - let txn = self.note.txn().expect("todo: support non-db notes"); + let txn = self.note.txn().expect("txn"); if let Some(note_to_repost) = get_reposted_note(self.ndb, txn, self.note) { let profile = self.ndb.get_profile_by_pubkey(txn, self.note.pubkey()); + let style = NotedeckTextStyle::Small; ui.horizontal(|ui| { ui.vertical(|ui| { ui.add_space(2.0); ui.add_sized([20.0, 20.0], repost_icon()); }); ui.add_space(6.0); - let resp = ui.add(one_line_display_name_widget(get_display_name( - profile.as_ref().ok(), - ))); + let resp = ui.add(one_line_display_name_widget( + get_display_name(profile.as_ref().ok()), + style, + )); if let Ok(rec) = &profile { resp.on_hover_ui_at_pointer(|ui| { ui.set_max_width(300.0); @@ -349,7 +351,8 @@ impl<'a> NoteView<'a> { ui.add_space(4.0); ui.label( RichText::new("Reposted") - .text_style(NotedeckTextStyle::Heading3.text_style()), + .color(colors::GRAY_SECONDARY) + .text_style(style.text_style()), ); }); NoteView::new(self.ndb, self.note_cache, self.img_cache, &note_to_repost).show(ui) diff --git a/src/ui/profile/preview.rs b/src/ui/profile/preview.rs @@ -198,17 +198,25 @@ fn display_name_widget( } } -pub fn one_line_display_name_widget(display_name: DisplayName<'_>) -> impl egui::Widget + '_ { +pub fn one_line_display_name_widget( + display_name: DisplayName<'_>, + style: NotedeckTextStyle, +) -> impl egui::Widget + '_ { + let text_style = style.text_style(); move |ui: &mut egui::Ui| match display_name { - DisplayName::One(n) => { - ui.label(RichText::new(n).text_style(NotedeckTextStyle::Heading3.text_style())) - } + DisplayName::One(n) => ui.label( + RichText::new(n) + .text_style(text_style) + .color(colors::GRAY_SECONDARY), + ), DisplayName::Both { display_name, username: _, } => ui.label( - RichText::new(display_name).text_style(NotedeckTextStyle::Heading3.text_style()), + RichText::new(display_name) + .text_style(text_style) + .color(colors::GRAY_SECONDARY), ), } }