timeline feed now automatically updates ever 10sec

This commit is contained in:
rozodru 2025-07-22 10:51:10 -04:00
parent 003ca8eb6b
commit 93c2aa102e
1 changed files with 16 additions and 1 deletions

View File

@ -46,6 +46,9 @@ pub async fn run_tui(mut app: App) -> Result<()> {
}
async fn run_app<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Result<()> {
let mut last_refresh = std::time::Instant::now();
let refresh_interval = Duration::from_secs(10);
loop {
terminal.draw(|f| ui(f, app))?;
@ -53,7 +56,19 @@ async fn run_app<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Resul
break;
}
let event_available = event::poll(Duration::from_millis(100))?;
// Auto-refresh timeline
if last_refresh.elapsed() >= refresh_interval {
if app.mode == AppMode::Timeline {
app.load_timeline().await?;
}
last_refresh = std::time::Instant::now();
}
let poll_duration = refresh_interval
.checked_sub(last_refresh.elapsed())
.unwrap_or_else(|| Duration::from_secs(0));
let event_available = event::poll(poll_duration.min(Duration::from_millis(100)))?;
if event_available {
let event = event::read()?;