fix(ui): fix slight responsiveness regression in 0.11.6

This commit is contained in:
Alex Pasmantier 2025-04-11 14:51:52 +02:00
parent e23c307649
commit ad40e2b63b

View File

@ -288,13 +288,27 @@ impl Television {
} }
} }
const RENDER_FIRST_N_TICKS: u64 = 20; /// Always render the first N ticks.
const RENDER_EVERY_N_TICKS: u64 = 10; ///
/// 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 { impl Television {
fn should_render(&self, action: &Action) -> bool { fn should_render(&self, action: &Action) -> bool {
self.ticks < RENDER_FIRST_N_TICKS self.ticks < FIRST_TICKS_TO_RENDER
|| self.ticks % RENDER_EVERY_N_TICKS == 0 || self.ticks % RENDERING_INTERVAL == 0
|| (self.channel.running()
&& self.ticks % RENDERING_INTERVAL_FAST == 0)
|| matches!( || matches!(
action, action,
Action::AddInputChar(_) Action::AddInputChar(_)
@ -322,7 +336,6 @@ impl Television {
| Action::TogglePreview | Action::TogglePreview
| Action::CopyEntryToClipboard | Action::CopyEntryToClipboard
) )
|| self.channel.running()
} }
pub fn update_preview_state( pub fn update_preview_state(