working notes + notes&replies

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-05-17 22:53:10 -05:00
parent 232ba0e3aa
commit 6fc5eb27fc
6 changed files with 161 additions and 62 deletions

View File

@@ -9,6 +9,20 @@ pub struct NoteCache {
pub cache: HashMap<NoteKey, CachedNote>,
}
impl NoteCache {
pub fn cached_note_or_insert_mut(&mut self, note_key: NoteKey, note: &Note) -> &mut CachedNote {
self.cache
.entry(note_key)
.or_insert_with(|| CachedNote::new(note))
}
pub fn cached_note_or_insert(&mut self, note_key: NoteKey, note: &Note) -> &CachedNote {
self.cache
.entry(note_key)
.or_insert_with(|| CachedNote::new(note))
}
}
pub struct CachedNote {
reltime: TimeCached<String>,
pub reply: NoteReplyBuf,