diff --git a/src/desktop/mod.rs b/src/desktop/mod.rs index 1dd8db7..15343ef 100644 --- a/src/desktop/mod.rs +++ b/src/desktop/mod.rs @@ -80,12 +80,11 @@ fn paused(sc: &mut StreamedContent, ui: &mut Ui, height: f32, tsize: f32) { fn streaming(sc: &mut StreamedContent, ui: &mut Ui, height: f32, tsize: f32, sleep: Duration) { let dur = Instant::now() - sc.last_packet_time; - let img = if dur < sleep { - if let Some(bytes) = sc.last_packet.clone() { - RetainedImage::from_image_bytes("last packet", &mk_qr_bytes(&bytes, height)).unwrap() - } else { - return; - } + // don't grab a new packet unless enough time has passed or we've never seen a + // packet before + let img = if dur < sleep && sc.last_packet.is_some() { + let bytes = sc.last_packet.clone().unwrap(); + RetainedImage::from_image_bytes("last packet", &mk_qr_bytes(&bytes, height)).unwrap() } else { let bytes = sc.rx.recv().unwrap(); sc.last_packet = Some(bytes.clone());