From ad40e2b63b106b42b05e969403f1001855c2a0cb Mon Sep 17 00:00:00 2001 From: Alex Pasmantier Date: Fri, 11 Apr 2025 14:51:52 +0200 Subject: [PATCH] fix(ui): fix slight responsiveness regression in 0.11.6 --- television/television.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/television/television.rs b/television/television.rs index 637d483..d0f90a0 100644 --- a/television/television.rs +++ b/television/television.rs @@ -288,13 +288,27 @@ impl Television { } } -const RENDER_FIRST_N_TICKS: u64 = 20; -const RENDER_EVERY_N_TICKS: u64 = 10; +/// Always render the first N ticks. +/// +/// This is to ensure there are no startup artefacts and the UI +/// stabilizes rapidly after startup. +const FIRST_TICKS_TO_RENDER: u64 = 10; +/// Render every N ticks. +/// +/// Without any user input, this is the default rendering interval. +const RENDERING_INTERVAL: u64 = 10; +/// Render every N ticks if the channel is currently running. +/// +/// This ensures that the UI stays in sync with the channel +/// state (displaying a spinner, updating results, etc.). +const RENDERING_INTERVAL_FAST: u64 = 3; impl Television { fn should_render(&self, action: &Action) -> bool { - self.ticks < RENDER_FIRST_N_TICKS - || self.ticks % RENDER_EVERY_N_TICKS == 0 + self.ticks < FIRST_TICKS_TO_RENDER + || self.ticks % RENDERING_INTERVAL == 0 + || (self.channel.running() + && self.ticks % RENDERING_INTERVAL_FAST == 0) || matches!( action, Action::AddInputChar(_) @@ -322,7 +336,6 @@ impl Television { | Action::TogglePreview | Action::CopyEntryToClipboard ) - || self.channel.running() } pub fn update_preview_state(