timeline: refactor tabs into TimelineView

TimelineView is a filtered view of a timeline. We will use this for
future tab rendering. We also introduce a new "selection" concept for
selecting notes on different timeline views. This is in preparation for
vim keybindings.
This commit is contained in:
William Casarin
2024-05-17 21:32:37 -05:00
parent 8663851e7e
commit a8693a2bd3
4 changed files with 156 additions and 30 deletions

View File

@@ -1,15 +1,21 @@
use crate::time::time_ago_since;
use crate::timecache::TimeCached;
use nostrdb::{Note, NoteReply, NoteReplyBuf};
use nostrdb::{Note, NoteKey, NoteReply, NoteReplyBuf};
use std::collections::HashMap;
use std::time::Duration;
#[derive(Default)]
pub struct NoteCache {
pub cache: HashMap<NoteKey, CachedNote>,
}
pub struct CachedNote {
reltime: TimeCached<String>,
pub reply: NoteReplyBuf,
pub bar_open: bool,
}
impl NoteCache {
impl CachedNote {
pub fn new(note: &Note<'_>) -> Self {
let created_at = note.created_at();
let reltime = TimeCached::new(
@@ -18,7 +24,7 @@ impl NoteCache {
);
let reply = NoteReply::new(note.tags()).to_owned();
let bar_open = false;
NoteCache {
CachedNote {
reltime,
reply,
bar_open,