nip10: show initial reply information on notes

Using the newly merged nip10 code, we can show replies on notes!

This is not final, and it's actually different than how we do it in
Damus iOS. Not sure if I like it yet. We will likely have to put pubkey
information back in somewhere soon.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-04-27 01:01:45 -07:00
parent afb0e5fe65
commit 69054d71ca
9 changed files with 208 additions and 71 deletions

View File

@@ -1,20 +1,28 @@
use crate::time::time_ago_since;
use crate::timecache::TimeCached;
use nostrdb::{Note, NoteReply, NoteReplyBuf};
use std::time::Duration;
pub struct NoteCache {
reltime: TimeCached<String>,
pub reply: NoteReplyBuf,
pub bar_open: bool,
}
impl NoteCache {
pub fn new(created_at: u64) -> Self {
pub fn new(note: &Note<'_>) -> Self {
let created_at = note.created_at();
let reltime = TimeCached::new(
Duration::from_secs(1),
Box::new(move || time_ago_since(created_at)),
);
let reply = NoteReply::new(note.tags()).to_owned();
let bar_open = false;
NoteCache { reltime, bar_open }
NoteCache {
reltime,
reply,
bar_open,
}
}
pub fn reltime_str(&mut self) -> &str {