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>
32 lines
774 B
Rust
32 lines
774 B
Rust
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(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,
|
|
reply,
|
|
bar_open,
|
|
}
|
|
}
|
|
|
|
pub fn reltime_str(&mut self) -> &str {
|
|
return self.reltime.get();
|
|
}
|
|
}
|