From ee29a3b1291e9cedd8b54c31fa9f273e39f51970 Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Tue, 7 Oct 2025 20:57:48 +0200 Subject: revamp subtitle selection --- src/transcript.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/transcript.rs') diff --git a/src/transcript.rs b/src/transcript.rs index 2bddb72..eb3459d 100644 --- a/src/transcript.rs +++ b/src/transcript.rs @@ -50,7 +50,7 @@ pub struct Transcript { #[derive(Debug)] pub enum TranscriptMsg { NewCue(StreamIndex, SubtitleCue), - SelectTrack(StreamIndex), + SelectTrack(Option), ScrollToCue(usize), } @@ -116,14 +116,17 @@ impl SimpleComponent for Transcript { } } TranscriptMsg::SelectTrack(stream_index) => { - self.active_stream_index = Some(stream_index); + self.active_stream_index = stream_index; // Clear current widgets and populate with selected track's cues self.active_cues.guard().clear(); - let tracks = TRACKS.read(); - if let Some(track) = tracks.get(&stream_index) { - for cue in &track.cues { - self.active_cues.guard().push_back(cue.clone()); + + if let Some(stream_ix) = stream_index { + let tracks = TRACKS.read(); + if let Some(track) = tracks.get(&stream_ix) { + for cue in &track.cues { + self.active_cues.guard().push_back(cue.clone()); + } } } } -- cgit 1.4.1