notedeck

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

commit ab84304265e36b8beee398af5f7dbc39a4b0c56d
parent 6a08d4b1b2ba8af6031fbd2d72628f50c9df6bfa
Author: Fernando López Guevara <fernando.lguevara@gmail.com>
Date:   Wed, 23 Jul 2025 17:49:33 -0300

feat(settings): show note full date

Diffstat:
MCargo.lock | 1+
MCargo.toml | 1+
Mcrates/notedeck/Cargo.toml | 1+
Mcrates/notedeck/src/lib.rs | 1+
Mcrates/notedeck/src/time.rs | 9+++++++++
Mcrates/notedeck_columns/src/nav.rs | 1+
Mcrates/notedeck_columns/src/ui/settings.rs | 21+++++++++++----------
Mcrates/notedeck_dave/Cargo.toml | 2+-
Mcrates/notedeck_ui/src/note/mod.rs | 6+++---
9 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -3485,6 +3485,7 @@ dependencies = [ "bincode", "bitflags 2.9.1", "blurhash", + "chrono", "dirs", "eframe", "egui", diff --git a/Cargo.toml b/Cargo.toml @@ -14,6 +14,7 @@ members = [ [workspace.dependencies] opener = "0.8.2" +chrono = "0.4.40" base32 = "0.4.0" base64 = "0.22.1" rmpv = "1.3.0" diff --git a/crates/notedeck/Cargo.toml b/crates/notedeck/Cargo.toml @@ -49,6 +49,7 @@ once_cell = { workspace = true } md5 = { workspace = true } bitflags = { workspace = true } regex = "1" +chrono = { workspace = true } [dev-dependencies] tempfile = { workspace = true } diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs @@ -80,6 +80,7 @@ pub use storage::{AccountStorage, DataPath, DataPathType, Directory}; pub use style::NotedeckTextStyle; pub use theme::ColorTheme; pub use time::time_ago_since; +pub use time::time_format; pub use timecache::TimeCached; pub use unknowns::{get_unknown_note_ids, NoteRefsUnkIdAction, SingleUnkIdAction, UnknownIds}; pub use urls::{supported_mime_hosted_at_url, SupportedMimeType, UrlMimes}; diff --git a/crates/notedeck/src/time.rs b/crates/notedeck/src/time.rs @@ -1,4 +1,5 @@ use crate::{tr, Localization}; +use chrono::DateTime; use std::time::{SystemTime, UNIX_EPOCH}; // Time duration constants in seconds @@ -83,6 +84,14 @@ fn time_ago_between(i18n: &mut Localization, timestamp: u64, now: u64) -> String } } +pub fn time_format(_i18n: &mut Localization, timestamp: i64) -> String { + // TODO: format this using the selected locale + DateTime::from_timestamp(timestamp, 0) + .unwrap() + .format("%Y-%m-%d %H:%M:%S") + .to_string() +} + pub fn time_ago_since(i18n: &mut Localization, timestamp: u64) -> String { let now = SystemTime::now() .duration_since(UNIX_EPOCH) diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs @@ -591,6 +591,7 @@ fn render_nav_body( ) .ui(ui) .map(RenderNavAction::SettingsAction), + Route::Reply(id) => { let txn = if let Ok(txn) = Transaction::new(ctx.ndb) { txn diff --git a/crates/notedeck_columns/src/ui/settings.rs b/crates/notedeck_columns/src/ui/settings.rs @@ -270,6 +270,7 @@ impl<'a> SettingsView<'a> { }); let txn = Transaction::new(self.note_context.ndb).unwrap(); + if let Some(note_id) = NoteId::from_bech(PREVIEW_NOTE_ID) { if let Ok(preview_note) = self.note_context.ndb.get_note_by_id(&txn, note_id.bytes()) @@ -277,17 +278,17 @@ impl<'a> SettingsView<'a> { notedeck_ui::padding(8.0, ui, |ui| { if is_narrow(ui.ctx()) { ui.set_max_width(ui.available_width()); - } - NoteView::new( - self.note_context, - &preview_note, - *self.note_options, - self.jobs, - ) - .actionbar(false) - .options_button(false) - .show(ui); + NoteView::new( + self.note_context, + &preview_note, + *self.note_options, + self.jobs, + ) + .actionbar(false) + .options_button(false) + .show(ui); + } }); ui.separator(); } diff --git a/crates/notedeck_dave/Cargo.toml b/crates/notedeck_dave/Cargo.toml @@ -18,7 +18,7 @@ serde_json = { workspace = true } serde = { workspace = true } nostrdb = { workspace = true } hex = { workspace = true } -chrono = "0.4.40" +chrono = { workspace = true } rand = "0.9.0" bytemuck = "1.22.0" futures = "0.3.31" diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs @@ -212,7 +212,7 @@ impl<'a, 'd> NoteView<'a, 'd> { let (_id, rect) = ui.allocate_space(egui::vec2(50.0, 20.0)); ui.allocate_rect(rect, Sense::hover()); ui.put(rect, |ui: &mut egui::Ui| { - render_reltime(ui, self.note_context.i18n, self.note.created_at(), false).response + render_notetime(ui, self.note_context.i18n, self.note.created_at(), false).response }); let (_id, rect) = ui.allocate_space(egui::vec2(150.0, 20.0)); ui.allocate_rect(rect, Sense::hover()); @@ -369,7 +369,7 @@ impl<'a, 'd> NoteView<'a, 'd> { ui.spacing_mut().item_spacing.x = if is_narrow(ui.ctx()) { 1.0 } else { 2.0 }; ui.add(Username::new(i18n, profile.as_ref().ok(), note.pubkey()).abbreviated(20)); - render_reltime(ui, i18n, note.created_at(), true); + render_notetime(ui, i18n, note.created_at(), true) }) .response; @@ -862,7 +862,7 @@ fn render_note_actionbar( } #[profiling::function] -fn render_reltime( +fn render_notetime( ui: &mut egui::Ui, i18n: &mut Localization, created_at: u64,